<!-- 火车 -->
<template>

    <div style="display: flex;">
        <div style="width:50%;">
            <el-form ref="order" :model="add_data" label-width="110px" label-suffix="：">
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="客户名称" :required="false">
                            <el-select @change='cusCompany_change' clearable style="width: 200px;" filterable remote
                                :filter-method="cusOptions_handleFilter" v-model="add_data.userId" placeholder="请选择客户">
                                <el-option v-for="(item, index) in cusOptions" :key="index" :label="item.cusCompanyName"
                                    :value="item.userId">
                                    <span style="float: left">{{ item.cusCompanyName }}</span>
                                    <span style="
                                float: right;
                                color: var(--el-text-color-secondary);
                                font-size: 13px;
                              ">{{ '（' + item.cusPhone + '）' }}</span>
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="负责人" :required="false">
                            <el-select :disabled="isTrustee == 1" clearable style="width: 200px;" filterable remote
                                :filter-method="getAllDutyOfCustom_handleFilter" v-model="add_data.useCarDutyUserId"
                                placeholder="请选择负责人">
                                <el-option v-for="(item, index) in getAllDutyOfCustom_list" :key="index"
                                    :label="item.realName" :value="item.ftUserId">
                                    <span style="float: left">{{ item.realName }}</span>
                                    <span style="
                                    float: right;
                                    color: var(--el-text-color-secondary);
                                    font-size: 13px;
                                  ">{{ '（' + item.loginPhone + '）' }}</span>
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="业务员" :required="false">
                            <el-select clearable style="width: 200px;" filterable remote
                                :filter-method="getServiceMans_handleFilter" v-model="add_data.serviceMan"
                                placeholder="请选择业务员">
                                <el-option v-for="(item, index) in getServiceMans_list" :key="index"
                                    :label="item.realName" :value="item.ftUserId">
                                    <span style="float: left">{{ item.realName }}</span>
                                    <span style="
                                float: right;
                                color: var(--el-text-color-secondary);
                                font-size: 13px;
                              ">{{ '（' + item.loginPhone + '）' }}</span>
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="4">
                        <el-button @click="train_se_btn(1)" style="margin-left:20px" type="primary">列车号自动查询</el-button>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="日期" :required="false">
                            <el-date-picker style=" width: 250px" value-format="YYYY-MM-DD" format="YYYY-MM-DD"
                                v-model="add_data.startTime" type="date" placeholder="请选择出发日期" />

                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="时间" :required="false">

                            <el-input type="number" v-model="time_number1" @change='time_number_change(1)'
                                style="width: 260px;margin-left:10px" placeholder="时间转换,格式:1201转换时间为12:01" clearable />
                        </el-form-item>
                    </el-col>
                </el-row>
                <div style="color:red;margin-bottom:10px;margin-left:25px;font-weight:700">
                    送火车:请首先选择目的地站点信息
                </div>
                <div v-if="aircraft_radio == '拼车'"
                    style="color:red;margin-bottom:10px;margin-left:25px;font-weight:700">
                    拼车：系统自动默认按照订单出发时间前后30分钟进行自动拼单！
                </div>
                <div style="display:flex;width:35vw;">

                    <el-form-item label="出发地址" :required="false">
                        <div v-if="includes_off() || includes_off2()">
                            <el-select :filter-method="fromLocation_handleFilter" clearable filterable remote
                                @change="aircraft_connect_change1" style="width:220px" v-model="add_data.fromLocation"
                                placeholder="请选择出发地址">
                                <el-option v-for="item in aircraft_list" :key="item.id" :label="item.station_name"
                                    :value="item.station_name">
                                    <span style="color: red;" v-if="item.station_name == '其他位置地图选址'">{{
                                        item.station_name }}</span>
                                    <span v-if="item.station_name != '其他位置地图选址'">{{ item.station_name }}</span>
                                </el-option>
                            </el-select>
                            <!-- <el-radio-group @change='radio_group_change' v-if="chartered_bus_off"
                                v-model="aircraft_radio" style="margin-left:20px;">
                                <el-radio label="包车" size="large">包车</el-radio>
                                <el-radio label="拼车" size="large">拼车</el-radio>

                            </el-radio-group> -->
                        </div>

                        <el-select v-else :filter-method="stationNamehandleFilter" clearable filterable remote
                            size="mini" style="width:220px" @change="select_Btn(1)" v-model="add_data.fromLocation"
                            class="m-2" placeholder="请选择出发地址">
                            <el-option v-for="item in getStationList_Data" :key="item.stationName"
                                :label="item.stationName" :value="item.stationName">
                                <span style="float: left">{{ item.stationName }}</span>
                                <span style="
                            float: right;
                            color: var(--el-text-color-secondary);
                            font-size: 13px;
                          ">{{ '（' + item.address + '）' }}</span>
                            </el-option>

                        </el-select>


                        <el-button v-if="address_off() || address_off3()" @click="map_off_btn(1)"
                            style="margin-left:30px;margin-bottom:0px" type="primary">地图选址</el-button>
                        <el-button v-if="aircraft_radio == '包车'" style="margin-left:30px;margin-bottom:0px"
                            @click="add_passing_points(1)" type="warning">添加途经点</el-button>
                    </el-form-item>

                </div>


                <template v-if="passing_points_list.length > 0">
                    <el-form-item v-for="(item, index) in passing_points_index" :key="index" label="途经地址">
                        <div style="display: flex;">
                            <div style="color:#108EE9;width:330px;overflow: hidden;white-space: nowrap;">
                                {{
                                    passing_points_list[index].area + '-' +
                                    passing_points_list[index].name
                                }}</div>

                            <div style="margin-left: 40px;">
                                <el-button @click="passing_points_index_delbtn(index)" type="danger" icon="Close" plain
                                    size="mini" title="删除途经">
                                    删除途经
                                </el-button>
                            </div>
                        </div>
                    </el-form-item>
                </template>
                <div style="display:flex;">
                    <el-form-item label="目的地址" :required="false">
                        <div v-if="includes_off() || includes_off3()">
                            <el-select id="name" data-name="1" :filter-method="fromLocation_handleFilter" clearable
                                filterable remote @change="aircraft_connect_change2" style="width:220px"
                                v-model="add_data.toLocation" placeholder="请选择目的地址">
                                <el-option v-for="item in aircraft_list" :key="item.id" :label="item.station_name"
                                    :value="item.station_name">
                                    <span style="color: red;" v-if="item.station_name == '其他位置地图选址'">{{
                                        item.station_name }}</span>
                                    <span v-if="item.station_name != '其他位置地图选址'">{{ item.station_name }}</span>
                                </el-option>
                            </el-select>
                            <!-- <el-radio-group @change='radio_group_change' v-if="chartered_bus_off"
                                v-model="aircraft_radio" style="margin-left:20px;">
                                <el-radio label="包车" size="large">包车</el-radio>
                                <el-radio label="拼车" size="large">拼车</el-radio>

                            </el-radio-group> -->
                        </div>



                        <el-select v-else :filter-method="stationNamehandleFilter" clearable filterable remote
                            size="mini" style="width:220px" @change="select_Btn(2)" v-model="add_data.toLocation"
                            class="m-2" placeholder="请选择目的地址">
                            <el-option v-for="item in getStationList_Data" :key="item.stationName"
                                :label="item.stationName" :value="item.stationName">
                                <span style="float: left">{{ item.stationName }}</span>
                                <span style="
                                float: right;
                                color: var(--el-text-color-secondary);
                                font-size: 13px;
                              ">{{ '（' + item.address + '）' }}</span>
                            </el-option>

                        </el-select>




                    </el-form-item>
                    <el-button v-if="address_off2() || address_off4()" @click="map_off_btn(2)"
                        style="margin-left:30px;margin-bottom:10px" type="primary">地图选址</el-button>


                </div>
                <el-form-item label="预约人数" :required="false">
                    <el-input type="number" style="width:220px" v-model="add_data.personNum" placeholder="请输入预约人数">
                        <template #append>人</template></el-input>
                </el-form-item>
                <el-row>
                    <el-col :span="8">
                        <el-form-item v-if="aircraft_radio != '拼车'" label="指定车型" :required="false">

                            <el-select @change="needSeats_change" v-model="add_data.needSeats" :filterable="false"
                                placeholder="请选择指定车型" style="width: 160px;">
                                <el-option label="不限车型" value="0"></el-option>
                                <el-option label="5座" value="5"></el-option>
                                <el-option label="7座" value="7"></el-option>
                                <el-option label="9座" value="9"></el-option>
                                <el-option label="12座" value="12"></el-option>
                                <el-option label="14座" value="14"></el-option>
                                <el-option label="17座" value="17"></el-option>
                                <el-option label="23座" value="23"></el-option>
                                <el-option label="30座" value="30"></el-option>
                                <el-option label="39座" value="39"></el-option>
                                <el-option label="49座" value="49"></el-option>
                                <el-option label="55座" value="55"></el-option>

                            </el-select></el-form-item>
                    </el-col>

                    <el-col :span="16">
                        <el-form-item v-if="aircraft_radio != '拼车' && add_data.needSeats > 0" label="车辆配置"
                            :required="false">

                            <el-select v-model="add_data.carConfig" :filterable="false" placeholder="请选择车辆配置"
                                style="width: 360px;">
                                <el-option v-for="item in getCarConfigurationType_list" :key="item.id"
                                    :label="item.text + '(' + item.other + ')'" :value="item.val" />

                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>

                <div style="display:flex;">
                    <el-form-item label="用车费用" :required="false">
                        <el-input type="number" style="width:220px" v-model="add_data.price" placeholder="请输入用车费用">
                            <template #append>元</template></el-input>
                    </el-form-item>

                    <el-button icon="PieChart" @click="price_btn(1)" style="margin-left:30px;margin-bottom:10px"
                        type="primary">自动计算价格</el-button>
                </div>

                <el-form-item label="联系人姓名" :required="false">
                    <el-input style="width:220px" v-model="add_data.cusName" placeholder="请输入联系人姓名" />
                </el-form-item>
                <div style="display:flex;">
                    <el-form-item type="number" label="联系人电话" :required="false">
                        <el-input style="width:220px" v-model="add_data.cusMobile" placeholder="请输入联系人电话" />
                    </el-form-item>
                    <el-button v-if="aircraft_radio != '拼车'" @click="add_cusName_btn(1)"
                        style="margin-left:30px;margin-bottom:10px" type="warning">添加联系人</el-button>
                </div>
                <template v-if="add_cusName_list.length > 0">
                    <el-form-item v-for="(item, index) in add_cusName_index" :key="index" label="联系人：">
                        <div style="display: flex;">
                            <div style="display: flex;">
                                <el-input style="width:220px" v-model="add_cusName_list[index].name"
                                    placeholder="请输入联系人姓名" />
                                <el-input style="width:220px" v-model="add_cusName_list[index].mobile"
                                    placeholder="请输入联系人电话" />
                            </div>

                            <div style="margin-left: 40px;">
                                <el-button @click="add_cusName_index_delbtn(index)" type="danger" icon="Close" plain
                                    size="mini" title="联系人">
                                    联系人
                                </el-button>
                            </div>
                        </div>
                    </el-form-item>
                </template>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="举牌接机" :required="false">
                            <el-input type="number" style="width:220px" v-model="add_data.riseSignPrice"
                                placeholder="举牌接机费用">
                                <template #append>元</template></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label-width="150px" label="中途吃饭或签合同" :required="false">
                            <el-input type="number" style="width:230px" v-model="add_data.wayEatPrice"
                                placeholder="中途吃饭或签合同费用">
                                <template #append>元</template></el-input>
                        </el-form-item>
                    </el-col>

                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="是否百推订单" :required="false">
                            <el-select v-model="add_data.isBaitui" :filterable="false" placeholder="是否百推订单"
                                style="width: 160px;">
                                <el-option label="是" value="1"></el-option>
                                <el-option label="否" value="0"></el-option>


                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item v-if="add_data.isBaitui == 1" label-width="130px" label="百推签单员电话"
                            :required="false">
                            <el-input maxlength="11" show-word-limit type="text" style="width:220px"
                                v-model="add_data.baituiSignatoryPhone" placeholder="百推签单员电话"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-form-item label="是否返程" :required="false">
                    <el-select @change="isReturnAdd_change" style="width:220px" v-model="add_data.isReturnAdd"
                        placeholder="请选择是否返程">
                        <el-option label="是" value="true" />
                        <el-option label="否" value="false" />
                    </el-select>
                </el-form-item>
                <el-form-item label="驾驶员备注" :required="false">
                    <el-input autosize show-word-limit maxlength="200" :rows="2" type="textarea" placeholder="请输入驾驶员备注"
                        v-model="add_data.driverRemark" />
                </el-form-item>
                <el-form-item label="业务员备注" :required="false">
                    <el-input autosize show-word-limit maxlength="200" :rows="2" type="textarea" placeholder="请输入业务员备注"
                        v-model="add_data.serviceManRemark" />
                </el-form-item>
                <el-form-item label="客户备注" :required="false">
                    <el-input autosize show-word-limit maxlength="200" :rows="3" type="textarea" placeholder="请输入客户备注"
                        v-model="add_data.remark" />
                </el-form-item>
            </el-form>
            <!-- 提交按钮 -->
            <div style="display: flex;margin-left:26vw;margin-top:70px">
                <el-button @click="clear_btn()" type="danger">重置数据</el-button>
                <el-button @click="ok_btn(1)" type="primary">保存</el-button>
                <el-button @click="ok_btn(2)" type="warning">保存并继续</el-button>
            </div>
        </div>
        <div style="height:74vh;margin: 20px 5px; width:3px;background-color:#c3b2b29c;"></div>
        <!-- 返程 -->
        <div style="width:50%" v-if="add_data.isReturnAdd == 'true'">
            <el-form ref="order" :model="add_data" label-width="110px" label-suffix="：">
                <el-form-item label-width="20px" :required="false">
                    <div style="font-weight:700;font-size:20px;color:red;">返程订单：</div>

                </el-form-item>
                <el-row>
                    <el-col :span="4">
                        <el-button @click="train_se_btn(2)" style="margin-left:20px" type="primary">列车号自动查询</el-button>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="日期" :required="false">
                            <el-date-picker @change="returnOrder_flightDate_change" style=" width: 250px"
                                value-format="YYYY-MM-DD" format="YYYY-MM-DD" v-model="add_data.returnOrder.startTime"
                                type="date" placeholder="请选择出发日期" />

                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="时间" :required="false">

                            <el-input type="number" v-model="time_number2" @change='time_number_change(2)'
                                style="width: 260px;margin-left:10px" placeholder="时间转换,格式:1201转换时间为12:01" clearable />
                        </el-form-item>
                    </el-col>
                </el-row>
                <div v-if="aircraft_radio2 == '拼车'"
                    style="color:red;margin-bottom:10px;margin-left:25px;font-weight:700">
                    拼车：系统自动默认按照订单出发时间前后30分钟进行自动拼单！
                </div>
                <div style="display:flex;width:35vw;">

                    <el-form-item label="出发地址" :required="false">
                        <div v-if="fan_includes_off()">
                            <el-select :filter-method="fromLocation_handleFilter" clearable filterable remote
                                @change="aircraft_connect_change3" style="width:220px"
                                v-model="add_data.returnOrder.fromLocation" placeholder="请选择出发地址">
                                <el-option v-for="item in aircraft_list" :key="item.id" :label="item.station_name"
                                    :value="item.station_name">
                                    <span style="color: red;" v-if="item.station_name == '其他位置地图选址'">{{
                                        item.station_name }}</span>
                                    <span v-if="item.station_name != '其他位置地图选址'">{{ item.station_name }}</span>
                                </el-option>
                            </el-select>
                            <!-- <el-radio-group @change='radio_group_change2' v-if="chartered_bus_off2"
                                v-model="aircraft_radio2" style="margin-left:20px;">
                                <el-radio label="包车" size="large">包车</el-radio>
                                <el-radio label="拼车" size="large">拼车</el-radio>

                            </el-radio-group> -->
                        </div>

                        <el-select v-else :filter-method="stationNamehandleFilter" clearable filterable remote
                            size="mini" style="width:220px" @change="select_Btn2(1)"
                            v-model="add_data.returnOrder.fromLocation" class="m-2" placeholder="请选择出发地址">
                            <el-option v-for="item in getStationList_Data" :key="item.stationName"
                                :label="item.stationName" :value="item.stationName">
                                <span style="float: left">{{ item.stationName }}</span>
                                <span style="
                            float: right;
                            color: var(--el-text-color-secondary);
                            font-size: 13px;
                          ">{{ '（' + item.address + '）' }}</span>
                            </el-option>

                        </el-select>


                        <el-button v-if="fan_address_off()" @click="map_off_btn(3)"
                            style="margin-left:30px;margin-bottom:0px" type="primary">地图选址</el-button>
                        <el-button v-if="aircraft_radio2 == '包车'" style="margin-left:30px;margin-bottom:0px"
                            @click="add_passing_points(2)" type="warning">添加途经点</el-button>
                    </el-form-item>

                </div>


                <template v-if="passing_points_list2.length > 0">
                    <el-form-item v-for="(item, index) in passing_points_index2" :key="index" label="途经地址">
                        <div style="display: flex;">
                            <div style="color:#108EE9;width:330px;overflow: hidden;white-space: nowrap;">
                                {{
                                    passing_points_list2[index].area + '-' +
                                    passing_points_list2[index].name
                                }}</div>

                            <div style="margin-left: 40px;">
                                <el-button @click="passing_points_index_delbtn2(index)" type="danger" icon="Close" plain
                                    size="mini" title="删除途经">
                                    删除途经
                                </el-button>
                            </div>
                        </div>
                    </el-form-item>
                </template>
                <div style="display:flex;">
                    <el-form-item label="目的地址" :required="false">
                        <div v-if="fan_includes_off2()">
                            <el-select :filter-method="fromLocation_handleFilter" clearable filterable remote
                                @change="aircraft_connect_change4" style="width:220px"
                                v-model="add_data.returnOrder.toLocation" placeholder="请选择目的地址">
                                <el-option v-for="item in aircraft_list" :key="item.id" :label="item.station_name"
                                    :value="item.station_name">
                                    <span style="color: red;" v-if="item.station_name == '其他位置地图选址'">{{
                                        item.station_name }}</span>
                                    <span v-if="item.station_name != '其他位置地图选址'">{{ item.station_name }}</span>
                                </el-option>
                            </el-select>
                            <!-- <el-radio-group @change='radio_group_change2' v-if="chartered_bus_off2"
                                v-model="aircraft_radio2" style="margin-left:20px;">
                                <el-radio label="包车" size="large">包车</el-radio>
                                <el-radio label="拼车" size="large">拼车</el-radio>

                            </el-radio-group> -->
                        </div>



                        <el-select v-else :filter-method="stationNamehandleFilter" clearable filterable remote
                            size="mini" style="width:220px" @change="select_Btn2(2)"
                            v-model="add_data.returnOrder.toLocation" class="m-2" placeholder="请选择目的地址">
                            <el-option v-for="item in getStationList_Data" :key="item.stationName"
                                :label="item.stationName" :value="item.stationName">
                                <span style="float: left">{{ item.stationName }}</span>
                                <span style="
                                float: right;
                                color: var(--el-text-color-secondary);
                                font-size: 13px;
                              ">{{ '（' + item.address + '）' }}</span>
                            </el-option>

                        </el-select>




                    </el-form-item>
                    <el-button v-if="fan_address_off2()" @click="map_off_btn(4)"
                        style="margin-left:30px;margin-bottom:10px" type="primary">地图选址</el-button>


                </div>
                <el-form-item label="预约人数" :required="false">
                    <el-input type="number" style="width:220px" v-model="add_data.returnOrder.personNum"
                        placeholder="请输入预约人数">
                        <template #append>人</template></el-input>
                </el-form-item>
                <el-row>
                    <el-col :span="8">
                        <el-form-item v-if="aircraft_radio2 != '拼车'" label="指定车型" :required="false">

                            <el-select @change="needSeats_change2" v-model="add_data.returnOrder.needSeats"
                                :filterable="false" placeholder="请选择指定车型" style="width: 160px;">
                                <el-option label="不限车型" value="0"></el-option>
                                <el-option label="5座" value="5"></el-option>
                                <el-option label="7座" value="7"></el-option>
                                <el-option label="9座" value="9"></el-option>
                                <el-option label="12座" value="12"></el-option>
                                <el-option label="14座" value="14"></el-option>
                                <el-option label="17座" value="17"></el-option>
                                <el-option label="23座" value="23"></el-option>
                                <el-option label="30座" value="30"></el-option>
                                <el-option label="39座" value="39"></el-option>
                                <el-option label="49座" value="49"></el-option>
                                <el-option label="55座" value="55"></el-option>

                            </el-select></el-form-item>
                    </el-col>

                    <el-col :span="16">
                        <el-form-item v-if="aircraft_radio2 != '拼车' && add_data.returnOrder.needSeats > 0" label="车辆配置"
                            :required="false">

                            <el-select v-model="add_data.returnOrder.carConfig" :filterable="false"
                                placeholder="请选择车辆配置" style="width: 360px;">
                                <el-option v-for="item in getCarConfigurationType_list2" :key="item.id"
                                    :label="item.text + '(' + item.other + ')'" :value="item.val" />

                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>

                <div style="display:flex;">
                    <el-form-item label="用车费用" :required="false">
                        <el-input type="number" style="width:220px" v-model="add_data.returnOrder.price"
                            placeholder="请输入用车费用">
                            <template #append>元</template></el-input>
                    </el-form-item>

                    <el-button icon="PieChart" @click="price_btn(2)" style="margin-left:30px;margin-bottom:10px"
                        type="primary">自动计算价格</el-button>
                </div>

                <el-form-item label="联系人姓名" :required="false">
                    <el-input style="width:220px" v-model="add_data.returnOrder.cusName" placeholder="请输入联系人姓名" />
                </el-form-item>
                <div style="display:flex;">
                    <el-form-item type="number" label="联系人电话" :required="false">
                        <el-input style="width:220px" v-model="add_data.returnOrder.cusMobile" placeholder="请输入联系人电话" />
                    </el-form-item>
                    <el-button v-if="aircraft_radio2 != '拼车'" @click="add_cusName_btn(2)"
                        style="margin-left:30px;margin-bottom:10px" type="warning">添加联系人</el-button>
                </div>
                <template v-if="add_cusName_list2.length > 0">
                    <el-form-item v-for="(item, index) in add_cusName_index2" :key="index" label="联系人：">
                        <div style="display: flex;">
                            <div style="display: flex;">
                                <el-input style="width:220px" v-model="add_cusName_list2[index].name"
                                    placeholder="请输入联系人姓名" />
                                <el-input style="width:220px" v-model="add_cusName_list2[index].mobile"
                                    placeholder="请输入联系人电话" />
                            </div>

                            <div style="margin-left: 40px;">
                                <el-button @click="add_cusName_index_delbtn2(index)" type="danger" icon="Close" plain
                                    size="mini" title="联系人">
                                    联系人
                                </el-button>
                            </div>
                        </div>
                    </el-form-item>
                </template>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="举牌接机" :required="false">
                            <el-input type="number" style="width:220px" v-model="add_data.returnOrder.riseSignPrice"
                                placeholder="举牌接机费用">
                                <template #append>元</template></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label-width="150px" label="中途吃饭或签合同" :required="false">
                            <el-input type="number" style="width:230px" v-model="add_data.returnOrder.wayEatPrice"
                                placeholder="中途吃饭或签合同费用">
                                <template #append>元</template></el-input>
                        </el-form-item>
                    </el-col>

                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="是否百推订单" :required="false">
                            <el-select v-model="add_data.returnOrder.isBaitui" :filterable="false" placeholder="是否百推订单"
                                style="width: 160px;">
                                <el-option label="是" value="1"></el-option>
                                <el-option label="否" value="0"></el-option>


                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item v-if="add_data.returnOrder.isBaitui == 1" label-width="130px" label="百推签单员电话"
                            :required="false">
                            <el-input maxlength="11" show-word-limit type="text" style="width:220px"
                                v-model="add_data.returnOrder.baituiSignatoryPhone" placeholder="百推签单员电话"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-form-item label="驾驶员备注" :required="false">
                    <el-input autosize show-word-limit maxlength="200" :rows="2" type="textarea" placeholder="请输入驾驶员备注"
                        v-model="add_data.returnOrder.driverRemark" />
                </el-form-item>
                <el-form-item label="业务员备注" :required="false">
                    <el-input autosize show-word-limit maxlength="200" :rows="2" type="textarea" placeholder="请输入业务员备注"
                        v-model="add_data.returnOrder.serviceManRemark" />
                </el-form-item>
                <el-form-item label="客户备注" :required="false">
                    <el-input autosize show-word-limit maxlength="200" :rows="3" type="textarea" placeholder="请输入客户备注"
                        v-model="add_data.returnOrder.remark" />
                </el-form-item>
            </el-form>
        </div>

        <!-- 弹窗 -->
        <!-- 列车选择 -->
        <el-dialog style="margin-top:5vh" v-model="train_se_off" title="列车号自动查询" width="40%"
            :close-on-click-modal='false'>
            <div>
                <div style="color:red">
                    列车号自动查询：到站时间系统会默认延后15分钟
                </div>
                <div style="color:red;margin-top:10px">
                    列车号自动查询：出发时间系统会默认提前2小时
                </div>
                <div style="margin-top:20px">
                    <el-form :model="train_se" label-width="110px" label-suffix="：">

                        <el-form-item label="列车号" :required="false">
                            <el-input style=" width: 200px" v-model="train_se.num" placeholder="请输入列车号" />
                        </el-form-item>
                        <el-form-item label="列车日期" :required="false">
                            <el-date-picker style=" width: 200px" value-format="YYYY-MM-DD" format="YYYY-MM-DD"
                                v-model="train_se.date" type="date" placeholder="请选择列车日期" />
                        </el-form-item>
                        <el-button @click="ok_train_se_btn" style="margin-left:30vw;margin-top:5px"
                            type="primary">确认查询</el-button>
                        <hr>
                        <div v-if="train_se_list.list" style="width: 80%;border-radius: 8px;background: antiquewhite;margin: auto;height: 500px;
                        ">
                            <div style="width:80%;height:100px;margin:0px auto;margin-top:10px;font-size:20px">
                                <div style="display: flex;justify-content: space-between;">
                                    <div style="display: flex;margin-top:10px;">
                                        <div style="font-weight:700">{{ train_se_list.trainno }}</div>
                                        <div style="font-weight:700;margin-left:10px">{{ train_se_list.typename }}</div>
                                    </div>
                                    <div style="color:#666;font-weight:700;margin-top:10px;">耗时&nbsp;&nbsp;{{
                                        train_se_list.costtimetxt
                                        }}
                                    </div>
                                </div>

                                <div style="display:flex;justify-content: center;align-items: center;">
                                    <div style="font-weight:700;margin-right:20px">{{ train_se_list.startstation }}
                                    </div>
                                    <el-icon :size="60">
                                        <DArrowRight />
                                    </el-icon>
                                    <div style="font-weight:700;margin-left:20px">{{ train_se_list.endstation }}</div>
                                </div>

                            </div>
                            <div style="height:2px;width:100%;background:#fff;"></div>
                            <div style="max-height:400px;width:100%;overflow: auto;min-height:200px;">
                                <div v-for="(item, index) in queryNow_list" :key="index">
                                    <div v-if="index == 0">
                                        <div
                                            style="display: flex;justify-content: space-between;height: 30px;align-items: center; ">
                                            <div style="color: #5AC725;font-weight:700;">{{ queryNow_list[0].station }}
                                                <text style="color: sandybrown;">(始发)</text>
                                            </div>
                                            <div @click="fa_btn(queryNow_list[0])"
                                                style="width: 100px;background-color:#3C9CFF;text-align: center;border-radius: 6px;color: #fff;padding: 5px 6px;">
                                                {{ queryNow_list[0].departuretime }}&nbsp;发车
                                            </div>

                                        </div>
                                        <div style="width: 100%;height: 1px;background-color: #F3F3F3;"></div>
                                    </div>
                                    <div v-if="index != 0 && index != (queryNow_list.length - 1)">
                                        <div
                                            style="display: flex;justify-content: space-between;height: 30px;align-items: center; ">
                                            <div style="font-weight:700;">{{ queryNow_list[index].station }}</div>
                                            <div @click="jin_btn(queryNow_list[index])"
                                                style="padding: 5px 6px; background-color:#5AC725;text-align: center;border-radius: 6px;color: #fff;">
                                                {{ queryNow_list[index].station.includes('成都') ? '接-' : "" }}{{
                                                    queryNow_list[index].arrivaltime }}&nbsp;进站
                                            </div>

                                        </div>
                                        <div
                                            style="display: flex;justify-content: space-between;height: 30px;align-items: center; ">
                                            <div style="color: rgb(147 136 25);font-weight:700;">停{{
                                                time_fun(queryNow_list[index]) }}分钟 </div>

                                            <div @click="fa_btn(queryNow_list[index])"
                                                style="padding: 5px 6px;background-color:#3C9CFF;text-align: center;border-radius: 6px;color: #fff;">
                                                {{ queryNow_list[index].station.includes('成都') ? '送-' : "" }}{{
                                                    queryNow_list[index].departuretime }}&nbsp;发车
                                            </div>
                                        </div>
                                        <div style="width: 100%;height: 2px;background-color: #F3F3F3;"></div>
                                    </div>
                                    <div v-if="index == (queryNow_list.length - 1)">
                                        <div
                                            style="display: flex;justify-content: space-between;height: 30px;align-items: center; ">
                                            <div style="color: red;font-weight:700;">{{
                                                queryNow_list[queryNow_list.length -
                                                    1].station }} <text style="color: sandybrown;">(终点)</text></div>
                                            <div @click="jin_btn(queryNow_list[queryNow_list.length - 1])"
                                                style="width: 100px;background-color:#5AC725;text-align: center;border-radius: 6px;color: #fff;padding: 5px 6px;">
                                                {{ queryNow_list[queryNow_list.length - 1].arrivaltime }}&nbsp;进站
                                            </div>

                                        </div>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </el-form>
                </div>
            </div>


        </el-dialog>
        <!-- 地图弹窗 -->
        <el-dialog style="margin-top:10vh;height:80vh;overflow: hidden;" v-model="map_off" title="选择地址:" width="80%"
            :close-on-click-modal='false'>
            <div class="div_map">
                <div class="map_input">
                    <el-input @input="map_change" id='tipinput' style="width:40%" v-model="map_address"
                        placeholder="请输入地址">
                        <template #prepend>选择地址:</template>
                    </el-input>
                    <el-button @click="map_ok_btn" type="primary">确认</el-button>
                </div>
                <div v-if="map_address_list.length > 0" class="map_input2">
                    <div style="width:40%;background:#fff;margin-left:20px;padding: 10px;font-weight: 700;">
                        <div @click="map_list_btn(item)" class="div_bg" v-for="(item, index) in map_address_list"
                            :key="index" style="margin-top: 10px;">
                            {{ item.area }}-{{ item.name }}-{{ item.address }}
                        </div>
                    </div>
                </div>
                <div id="myMap" style="height: 65vh; width: 100%">
                </div>
            </div>
        </el-dialog>

        <!-- 地址弹窗 -->
        <el-dialog style="margin-top:10vh;height:80vh;overflow: hidden;" v-model="map2_off" title="选择地址:" width="50%"
            :close-on-click-modal='false'>
            <div class="div_map">
                <div class="map_input">
                    <el-input @input="stationNamehandleFilter(map_address_name)" style="width:60%"
                        v-model="map_address_name" placeholder="请输入地址">
                        <template #prepend>选择地址:</template>
                    </el-input>
                    <el-button @click="map_off_btn2(address_map_off)" type="primary">地图选址</el-button>
                </div>
                <div class="map_input2">
                    <div style="width:60%;background:#fff;padding: 10px;font-weight: 700;height:65vh;overflow: auto;">
                        <div @click="map_list_btn2(item)" class="div_bg" v-for="(item, index) in getStationList_Data"
                            :key="index" style="margin-top: 10px;background:#ddd;padding: 10px;border-radius: 8px;">
                            【 {{ item.stationName }}】{{ item.address }}
                        </div>
                    </div>
                </div>
            </div>
        </el-dialog>

    </div>

</template>

<script setup>
import { GET_TOKEN } from '@/utils/token.js'
import { ref, reactive, onMounted, computed, watch } from 'vue'
import {
    getOrderList, findTravelWayInfo, getStationListPages, add, findStationCombo, getStationType, findAddressByLocation, findMapPointList,
    edit, omsorderdelete, getOrderInfo, mergeQuery, merge, omsorderexport, cancelMerge, adupPrivateSet, getPrivateSetList, getPrice,
    findComboCusList, getAllDutyOfCustom, getServiceMans, getCarConfigurationType
} from '@/api/original_order_list.js'
import { ElMessage, ElLoading, ElMessageBox } from 'element-plus'
import AMapLoader from "@amap/amap-jsapi-loader"
import { securityJsCode, key, importCusCheckInData } from '@/utils/common.js'
import { useRouter, useRoute } from 'vue-router'
import CircularJSON from 'circular-json'
const $useRouter = useRouter()
const $useRoute = useRoute()
import mainStore from '@/store/main/index.js'
let $mainStore = mainStore()
onMounted(() => {
    findComboCusList_api()
    getServiceMans_api()
    address_data()
    company.value = JSON.parse(localStorage.getItem("company"))
    isTrustee.value = company.value.isTrustee
})
//#region 是否托管
const company = ref({})
const isTrustee = ref(0)
//#endregion
// #region 订单数据
const add_data = reactive({
    cusInfo: [],
    cusMobile: '', // 乘车人电话
    cusName: '', // 乘车人
    days: '',
    endTime: '',
    flightDate: '',// 航班起飞时间 yyyy-MM-dd HH:mm
    flightNum: "",// 航班号
    flightTime: '',
    fromLocation: "",// 出发地名称
    fromLocationData: {
        address: '',
        area: '',
        id: "",
        isSta: "",
        lnglat: "",
        name: "",
        tel: "",
        type: ""
    },// 出发地
    fromLocationId: '',// 出发地主数据id(接天府肯定有)
    isReturnAdd: "false",// 是否返程,true,false
    landDate: '',// 航班降落时间 yyyy-MM-dd HH:mm
    needSeats: '0',
    priceNeedSeats: '',
    carConfig: '',
    personNum: '',// 预约人数
    receiveMsg: 'false',// true通知,false不通知
    remark: '',// 备注
    serviceManRemark: '',//业务员备注
    driverRemark: '',
    returnTime: '',// 返程时间,yyyy-MM-dd HH:mm:ss
    routeSimpleName: '',// 行程简称,拼车接天府/拼送天府
    startTime: '',
    toLocation: '',// 目的地名称
    toLocationData: {
        address: '',
        area: '',
        id: "",
        isSta: "",
        lnglat: "",
        name: "",
        tel: "",
        type: ""
    },// 目的地
    toLocationId: '',// 目的地主数据id(送天府肯定有)
    userId: '',// 用户Id,对应Customers表数据的id
    useCarDutyUserId: '',
    useCarCompanyName: '',
    useCarDutyInfo: '',
    serviceMan: '',
    type: '',
    price: '',
    ensureMoney: '',
    regularCarMoney: '',
    points: [],
    persons: [],
    id: '',
    wayEatPrice: '0',
    isBaitui: '0',
    baituiSignatoryPhone: '',
    riseSignPrice: '0',
    returnOrder: {
        cusMobile: '', // 乘车人电话
        cusName: '', // 乘车人
        days: '',
        endTime: '',
        flightDate: '',// 航班起飞时间 yyyy-MM-dd HH:mm
        flightNum: "",// 航班号
        flightTime: '',
        fromLocation: "",// 出发地名称
        fromLocationData: {
            address: '',
            area: '',
            id: "",
            isSta: "",
            lnglat: "",
            name: "",
            tel: "",
            type: ""
        },// 出发地
        fromLocationId: '',// 出发地主数据id(接天府肯定有)
        landDate: '',// 航班降落时间 yyyy-MM-dd HH:mm
        needSeats: '0',
        priceNeedSeats: '',
        carConfig: '',
        personNum: '',// 预约人数
        receiveMsg: 'false',// true通知,false不通知
        remark: '',// 备注
        serviceManRemark: '',//业务员备注
        driverRemark: '',
        routeSimpleName: '',// 行程简称,拼车接天府/拼送天府
        startTime: '',
        toLocation: '',// 目的地名称
        toLocationData: {
            address: '',
            area: '',
            id: "",
            isSta: "",
            lnglat: "",
            name: "",
            tel: "",
            type: ""
        },// 目的地
        toLocationId: '',// 目的地主数据id(送天府肯定有)
        userId: '',// 用户Id,对应Customers表数据的id
        userId: '',
        useCarDutyUserId: '',
        useCarCompanyName: '',
        useCarDutyInfo: '',
        serviceMan: '',
        type: '',
        price: '',
        ensureMoney: '',
        regularCarMoney: '',
        points: [],
        persons: [],
        cusInfo: [],
        wayEatPrice: '0',
        isBaitui: '0',
        baituiSignatoryPhone: '',
        riseSignPrice: '0',
    },
})
// #endregion
// #region 客户名称，负责人，业务员
const cusOptions = ref([])
const cusOptions2 = ref([])
const getAllDutyOfCustom_list = ref([])
const getAllDutyOfCustom_list2 = ref([])
const getServiceMans_list = ref([])
const getServiceMans_list2 = ref([])
const findComboCusList_api = () => {

    findComboCusList({
        find: '',
        page: {
            pageNum: 1,
            pageSize: 999,
        },
    }).then(res => {
        if (res.code == 1) {
            cusOptions.value = res.data;
            cusOptions2.value = res.data;
        }
    })
}
const cusOptions_handleFilter = (value) => {
    // 自定义筛选逻辑
    if (value) {
        let results = cusOptions2.value.filter(item => {
            for (let key in item) {
                if (typeof item[key] === 'string' && item[key].includes(value)) {
                    return true;
                }
            }
            return false;
        })
        if (results.length > 0) {
            cusOptions.value = results
        } else {
            cusOptions.value = []
        }
    } else {
        cusOptions.value = cusOptions2.value
    }
}
const cusCompany_change = (e) => {
    let data = {}
    for (let i = 0; i < cusOptions2.value.length; i++) {
        if (e == cusOptions2.value[i].userId) {
            data = cusOptions2.value[i]



            getAllDutyOfCustom_list.value = []
            getAllDutyOfCustom_list2.value = []
            if (data.dutyService) {
                let dutyService = data.dutyService.split(',')
                if (dutyService) {
                    add_data.useCarDutyUserId = dutyService[0].split('-')[0]
                    for (let i = 0; i < dutyService.length; i++) {
                        let dutyService_data = {
                            ftUserId: '',
                            loginPhone: '',
                            realName: '',
                        }



                        dutyService_data.ftUserId = dutyService[i].split('-')[0]
                        dutyService_data.loginPhone = dutyService[i].split('-')[2]
                        dutyService_data.realName = dutyService[i].split('-')[1]

                        getAllDutyOfCustom_list.value.push(dutyService_data)
                        getAllDutyOfCustom_list2.value.push(dutyService_data)
                    }
                } else {

                    return ElMessage({
                        message: '该客户负责人信息错误，请联系管理员处理',
                        type: 'warning',
                    })
                }
            } else {
                getAllDutyOfCustom_list.value = []
                getAllDutyOfCustom_list2.value = []
                return ElMessage({
                    message: '该客户没有负责人，请联系管理员处理',
                    type: 'warning',
                })
            }

            if (data.serviceMan) {

                let serviceMan = data.serviceMan.split(',')
                if (serviceMan) {

                    let serviceMan_id = serviceMan[0].split('-')[0]
                    for (let i = 0; i < getServiceMans_list2.value.length; i++) {
                        if (serviceMan_id == getServiceMans_list2.value[i].ftUserId) {
                            let data = getServiceMans_list2.value[i]
                            add_data.serviceMan = data.ftUserId
                        }
                    }


                } else {
                    return ElMessage({
                        message: '该客户没有业务员，请联系管理员处理',
                        type: 'warning',
                    })
                }

            }

        }
    }

}
const getServiceMans_api = () => {

    getServiceMans({

    }).then(res => {
        if (res.code == 1) {
            getServiceMans_list.value = res.data;
            getServiceMans_list2.value = res.data;

        }
    })
}
const getServiceMans_handleFilter = (value) => {
    // 自定义筛选逻辑
    if (value) {
        let results = getServiceMans_list2.value.filter(item => {
            for (let key in item) {
                if (typeof item[key] === 'string' && item[key].includes(value)) {
                    return true;
                }
            }
            return false;
        })
        if (results.length > 0) {
            getServiceMans_list.value = results
        } else {
            getServiceMans_list.value = []
        }
    } else {
        getServiceMans_list.value = getServiceMans_list2.value
    }
}
// #endregion
//#region 列车查询
const train_se_off = ref(false)
const train_se = reactive({
    date: '',
    num: '',
    travelWay: '2'
})
const train_se_list = ref({})
const queryNow_list = ref([])
const train_se_btn_num = ref('1') // 1是顺，2是返程
const train_se_btn = (e) => {
    if (e == 1) {
        queryNow_list.value = []
        train_se.date = ''
        train_se.num = ''
        train_se_list.value = {}
        train_se_btn_num.value = '1'
        train_se_off.value = true
    } else if (e == 2) {
        if (add_data.fromLocation && add_data.toLocation) {
            queryNow_list.value = []
            train_se.date = ''
            train_se.num = ''
            train_se_list.value = {}
            train_se_btn_num.value = '2'
            train_se_off.value = true
        } else {
            return ElMessage({
                message: '请先完成顺程地址信息填写',
                type: 'warning',
            })
        }


    }
}

const ok_train_se_btn = () => {
    if (!train_se.date) {
        return ElMessage({
            message: '请输入列车时间',
            type: 'warning',
        })
    } else if (!train_se.num) {
        return ElMessage({
            message: '请输入列车号',
            type: 'warning',
        })
    }

    findTravelWayInfo(train_se).then(res => {
        if (res.code == 1) {
            train_se_list.value = res.data.data
            queryNow_list.value = res.data.data.list
            return ElMessage({
                message: res.msg,
                type: 'success',
            })
        } else {
            return ElMessage({
                message: res.msg,
                type: 'warning',
            })
        }
    })
}

const time_fun = (e) => {
    let datatime1 = e.departuretime
    let datatime2 = e.arrivaltime
    let parts1 = datatime1.split(':')
    let parts2 = datatime2.split(':')
    let num1 = parseInt(parts1[0]) * 60 + parseInt(parts1[1])
    let num2 = parseInt(parts2[0]) * 60 + parseInt(parts2[1])
    let difference = Math.abs(num1 - num2);
    return difference
}

const fa_btn = (e) => {
    let timedate = train_se.date + ' ' + e.departuretime
    if (e.station.includes('成都')) {
        if (train_se_btn_num.value == '1') {
            if (e.station.includes('成都东')) {
                add_data.flightNum = train_se_list.value.trainno
                add_data.flightDate = add2hours(timedate)
                add_data.startTime = add_data.flightDate.split(' ')[0]
                time_number1.value = add_data.flightDate.split(' ')[1].replace(':', '')
                add_data.toLocation = '成都东站'

            } else if (e.station.includes('成都西')) {
                add_data.flightNum = train_se_list.value.trainno
                add_data.flightDate = add2hours(timedate)
                add_data.startTime = add_data.flightDate.split(' ')[0]
                time_number1.value = add_data.flightDate.split(' ')[1].replace(':', '')
                add_data.toLocation = '成都西站'
            } else if (e.station.includes('成都南')) {
                add_data.flightNum = train_se_list.value.trainno
                add_data.flightDate = add2hours(timedate)
                add_data.startTime = add_data.flightDate.split(' ')[0]
                time_number1.value = add_data.flightDate.split(' ')[1].replace(':', '')
                add_data.toLocation = '成都南站'
            } else if (e.station.includes('成都北')) {
                add_data.flightNum = train_se_list.value.trainno
                add_data.flightDate = add2hours(timedate)
                add_data.startTime = add_data.flightDate.split(' ')[0]
                time_number1.value = add_data.flightDate.split(' ')[1].replace(':', '')
                add_data.toLocation = '成都北站'
            }
        } else if (train_se_btn_num.value == '2') {
            if (e.station.includes('成都东')) {
                add_data.returnOrder.flightNum = train_se_list.value.trainno
                add_data.returnOrder.flightDate = add2hours(timedate)
                add_data.returnOrder.startTime = add_data.returnOrder.flightDate.split(' ')[0]
                time_number2.value = add_data.returnOrder.flightDate.split(' ')[1].replace(':', '')
                add_data.returnOrder.toLocation = '成都东站'

            } else if (e.station.includes('成都西')) {
                add_data.returnOrder.flightNum = train_se_list.value.trainno
                add_data.returnOrder.flightDate = add2hours(timedate)
                add_data.returnOrder.startTime = add_data.returnOrder.flightDate.split(' ')[0]
                time_number2.value = add_data.returnOrder.flightDate.split(' ')[1].replace(':', '')
                add_data.returnOrder.toLocation = '成都西站'
            } else if (e.station.includes('成都南')) {
                add_data.returnOrder.flightNum = train_se_list.value.trainno
                add_data.returnOrder.flightDate = add2hours(timedate)
                add_data.returnOrder.startTime = add_data.returnOrder.flightDate.split(' ')[0]
                time_number2.value = add_data.returnOrder.flightDate.split(' ')[1].replace(':', '')
                add_data.returnOrder.toLocation = '成都南站'
            } else if (e.station.includes('成都北')) {
                add_data.returnOrder.flightNum = train_se_list.value.trainno
                add_data.returnOrder.flightDate = add2hours(timedate)
                add_data.returnOrder.startTime = add_data.returnOrder.flightDate.split(' ')[0]
                time_number2.value = add_data.returnOrder.flightDate.split(' ')[1].replace(':', '')
                add_data.returnOrder.toLocation = '成都北站'
            }
        } else {
            return ElMessage({
                message: '列车行程有误',
                type: 'warning',
            })
        }

        train_se_off.value = false



    } else {
        return ElMessage({
            message: e.station + '业务暂未开通',
            type: 'warning',
        })
    }
}
const jin_btn = (e) => {

    let timedate = train_se.date + ' ' + e.arrivaltime

    if (e.station.includes('成都')) {
        if (train_se_btn_num.value == '1') {
            if (e.station.includes('成都东')) {
                add_data.flightNum = train_se_list.value.trainno
                add_data.landDate = add15Minutes(timedate)
                add_data.startTime = add_data.landDate.split(' ')[0]
                time_number1.value = add_data.landDate.split(' ')[1].replace(':', '')
                add_data.fromLocation = '成都东站'

            } else if (e.station.includes('成都西')) {
                add_data.flightNum = train_se_list.value.trainno
                add_data.landDate = add15Minutes(timedate)
                add_data.startTime = add_data.landDate.split(' ')[0]
                time_number1.value = add_data.landDate.split(' ')[1].replace(':', '')
                add_data.fromLocation = '成都西站'
            } else if (e.station.includes('成都南')) {
                add_data.flightNum = train_se_list.value.trainno
                add_data.landDate = add15Minutes(timedate)
                add_data.startTime = add_data.landDate.split(' ')[0]
                time_number1.value = add_data.landDate.split(' ')[1].replace(':', '')
                add_data.fromLocation = '成都南站'
            } else if (e.station.includes('成都北')) {
                add_data.flightNum = train_se_list.value.trainno
                add_data.landDate = add15Minutes(timedate)
                add_data.startTime = add_data.landDate.split(' ')[0]
                time_number1.value = add_data.landDate.split(' ')[1].replace(':', '')
                add_data.fromLocation = '成都北站'
            }
        } else if (train_se_btn_num.value == '2') {
            if (e.station.includes('成都东')) {
                add_data.returnOrder.flightNum = train_se_list.value.trainno
                add_data.returnOrder.landDate = add15Minutes(timedate)
                add_data.returnOrder.startTime = add_data.returnOrder.landDate.split(' ')[0]
                time_number2.value = add_data.returnOrder.landDate.split(' ')[1].replace(':', '')
                add_data.returnOrder.fromLocation = '成都东站'

            } else if (e.station.includes('成都西')) {
                add_data.returnOrder.flightNum = train_se_list.value.trainno
                add_data.returnOrder.landDate = add15Minutes(timedate)
                add_data.returnOrder.startTime = add_data.returnOrder.landDate.split(' ')[0]
                time_number2.value = add_data.returnOrder.landDate.split(' ')[1].replace(':', '')
                add_data.returnOrder.fromLocation = '成都西站'
            } else if (e.station.includes('成都南')) {
                add_data.returnOrder.flightNum = train_se_list.value.trainno
                add_data.returnOrder.landDate = add15Minutes(timedate)
                add_data.returnOrder.startTime = add_data.returnOrder.landDate.split(' ')[0]
                time_number2.value = add_data.returnOrder.landDate.split(' ')[1].replace(':', '')
                add_data.returnOrder.fromLocation = '成都南站'
            } else if (e.station.includes('成都北')) {
                add_data.returnOrder.flightNum = train_se_list.value.trainno
                add_data.returnOrder.landDate = add15Minutes(timedate)
                add_data.returnOrder.startTime = add_data.returnOrder.landDate.split(' ')[0]
                time_number2.value = add_data.returnOrder.landDate.split(' ')[1].replace(':', '')
                add_data.returnOrder.fromLocation = '成都北站'
            }
        } else {
            return ElMessage({
                message: '列车行程有误',
                type: 'warning',
            })
        }
        train_se_off.value = false


    } else {
        return ElMessage({
            message: e.station + '业务暂未开通',
            type: 'warning',
        })
    }
}

// 时间增加15分钟
const add15Minutes = (dateTimeStr) => {
    let date = new Date(dateTimeStr);
    date.setMinutes(date.getMinutes() + 15);

    let year = date.getFullYear();
    let month = (date.getMonth() + 1).toString().padStart(2, '0');
    let day = date.getDate().toString().padStart(2, '0');
    let hours = date.getHours().toString().padStart(2, '0');
    let minutes = date.getMinutes().toString().padStart(2, '0');

    let newDateTimeStr = `${year}-${month}-${day} ${hours}:${minutes}`;
    return newDateTimeStr;
}
// 时间提前2个小时
const add2hours = (dateString) => {
    console.log(dateString);
    // 将时间字符串转换为日期对象
    let dateObj = new Date(dateString);

    // 将时间提前4个小时
    dateObj.setHours(dateObj.getHours() - 2);

    // 格式化新的日期时间
    let year = dateObj.getFullYear();
    let month = ("0" + (dateObj.getMonth() + 1)).slice(-2);
    let day = ("0" + dateObj.getDate()).slice(-2);
    let hours = ("0" + dateObj.getHours()).slice(-2);
    let minutes = ("0" + dateObj.getMinutes()).slice(-2);

    let newDateString = year + "-" + month + "-" + day + " " + hours + ":" + minutes;

    console.log(newDateString);
    // 输出新的日期时间字符串
    return newDateString;


}
//#endregion
// #region 时间
const time_number1 = ref('')// 正
const time_number2 = ref('')// 反
const time_number_change = (e) => {
    // e == 1顺程 e==2返程
    if (e == 1) {
        if (!add_data.startTime) {
            time_number1.value = ''
            return ElMessage({
                message: '请先选择日期',
                type: 'warning',
            })
        } else if (time_number1.value.length != 4) {
            time_number1.value = ''
            return ElMessage({
                message: '时间格式不对，列12:01请输入1201',
                type: 'warning',
            })
        } else if (time_number1.value[0] > 2) {
            time_number1.value = ''
            return ElMessage({
                message: '时间格式不对，首数字不能大于2',
                type: 'warning',
            })
        } else if (time_number1.value[0] == 2) {

            if (time_number1.value[1] > 4) {
                time_number1.value = ''
                return ElMessage({
                    message: '时间格式不对，列12:01请输入1201',
                    type: 'warning',
                })
            }

        }
    } else if (e == 2) {
        if (!add_data.returnOrder.startTime) {
            time_number2.value = ''
            return ElMessage({
                message: '请先选择日期',
                type: 'warning',
            })
        } else if (time_number2.value.length != 4) {
            time_number2.value = ''
            return ElMessage({
                message: '时间格式不对，列12:01请输入1201',
                type: 'warning',
            })
        } else if (time_number2.value[0] > 2) {
            time_number2.value = ''
            return ElMessage({
                message: '时间格式不对，首数字不能大于2',
                type: 'warning',
            })
        } else if (time_number2.value[0] == 2) {

            if (time_number2.value[1] > 4) {
                time_number2.value = ''
                return ElMessage({
                    message: '时间格式不对，列12:01请输入1201',
                    type: 'warning',
                })
            }

        }
    } else {
        return ElMessage({
            message: '时间有误',
            type: 'warning',
        })
    }

}
const returnOrder_flightDate_change = () => {
    if (add_data.startTime && add_data.returnOrder.startTime) {
        let time1 = add_data.startTime
        let time2 = add_data.returnOrder.startTime
        time1 = new Date(time1).getTime()
        time2 = new Date(time2).getTime()
        if (time2 < time1) {
            add_data.returnOrder.startTime = ''
            return ElMessage({
                message: '返程订单时间不能小于正常订单时间',
                type: 'warning',
            })
        }
    }
}
// #endregion
//#region 出发地址 目的地址
const aircraft_list = ref([])
const aircraft_list2 = ref([])
const getStationList_Data = ref([])
const getStationList_Data2 = ref([])
const includes_off = () => {
    let data = false
    if (!add_data.toLocation && !add_data.fromLocation) {
        data = true
    }
    return data
}
const includes_off2 = () => {
    let data = false
    if (add_data.fromLocation && !add_data.toLocation) {
        data = true
    }
    if (add_data.fromLocation && add_data.toLocation) {
        if (add_data.fromLocation.includes('站') && !add_data.fromLocation.includes('停车')) {
            data = true
        }
    }
    if (add_data.toLocation && !add_data.fromLocation) {
        if (!add_data.toLocation.includes('站')) {
            data = true
        } else {
            if (add_data.toLocation.includes('停车')) {
                data = true
            }
        }
    }
    return data
}
const includes_off3 = () => {
    let data = false
    if (add_data.toLocation && !add_data.fromLocation) {
        data = true
    }
    if (add_data.fromLocation && add_data.toLocation) {
        if (add_data.toLocation.includes('站') && !add_data.toLocation.includes('停车')) {
            data = true
        }
    }
    if (add_data.fromLocation && !add_data.toLocation) {
        if (!add_data.fromLocation.includes('站')) {
            data = true
        } else {
            if (add_data.fromLocation.includes('停车')) {
                data = true
            }
        }
    }
    return data
}
const fan_includes_off = () => {
    let data = false
    if (includes_off() || includes_off2()) {
        data = false
    } else {
        data = true
    }
    return data
}
const fan_includes_off2 = () => {
    let data = false
    if (includes_off() || includes_off3()) {
        data = false
    } else {
        data = true
    }
    return data
}

const address_off = () => {
    let data = false
    if (add_data.toLocation && !add_data.fromLocation) {
        if (add_data.toLocation.includes('站')) {
            if (!add_data.toLocation.includes('停车')) {
                data = true
            }

        }
    }
    return data
}
const address_off2 = () => {
    let data = false
    if (add_data.fromLocation && !add_data.toLocation) {

        if (add_data.fromLocation.includes('站')) {
            if (!add_data.fromLocation.includes('停车')) {
                data = true
            }

        }
    }
    return data
}
const address_off3 = () => {
    let data = false
    if (add_data.fromLocation) {
        if (add_data.fromLocation.includes('站')) {
            if (add_data.fromLocation.includes('停车')) {
                data = true
            }

        } else {
            data = true
        }

    }
    return data
}
const address_off4 = () => {
    let data = false
    if (add_data.toLocation) {
        if (add_data.toLocation.includes('站')) {
            if (add_data.toLocation.includes('停车')) {
                data = true
            }

        } else {
            data = true
        }

    }
    return data
}
const address_data = () => {
    findStationCombo({
        page: {
            pageNum: 1,
            pageSize: 999,
        },
        stationTypes: ['TRAIN']
    }).then(res => {
        let obj = {
            station_name: '其他位置地图选址',
            lng_lat: '',
            id: '',
        }
        let datalist = res.data.list
        datalist.push(obj)
        aircraft_list.value = datalist
        aircraft_list2.value = datalist
    })

    getStationListPages({
        page: {
            pageNum: 1,
            pageSize: 999,
        },
        stationTypes: ['DIY'],
    }).then(res => {
        if (res.code == 1) {
            getStationList_Data.value = res.data.list
            getStationList_Data2.value = res.data.list
        }
    })


}
const fan_address_off = () => {
    let data = false
    if (address_off() || address_off3()) {
        data = false
    } else {
        data = true
    }
    return data
}
const fan_address_off2 = () => {
    let data = false
    if (address_off2() || address_off4()) {
        data = false
    } else {
        data = true
    }
    return data
}
const fromLocation_handleFilter = (value) => {
    // 自定义筛选逻辑
    if (value) {
        let results = aircraft_list2.value.filter(item => {
            for (let key in item) {
                if (typeof item[key] === 'string' && item[key].includes(value)) {
                    return true;
                }
            }
            return false;
        })
        if (results.length > 0) {
            aircraft_list.value = results
        } else {
            aircraft_list.value = []
        }
    } else {
        aircraft_list.value = aircraft_list2.value
    }
}
const stationNamehandleFilter = (value) => {
    // 自定义筛选逻辑
    if (value) {
        let results = getStationList_Data2.value.filter(item => {
            for (let key in item) {
                if (typeof item[key] === 'string' && item[key].includes(value)) {
                    return true;
                }
            }
            return false;
        })
        if (results.length > 0) {
            getStationList_Data.value = results
        } else {
            getStationList_Data.value = []
        }
    } else {
        getStationList_Data.value = getStationList_Data2.value
    }
}
const select_Btn = (item) => {

    if (item == 1) {
        let data = add_data.fromLocation
        let obj = {}
        for (let i = 0; i < getStationList_Data2.value.length; i++) {
            if (data == getStationList_Data2.value[i].stationName) {
                obj = getStationList_Data2.value[i]
            }

        }
        add_data.fromLocation = obj.stationName
        add_data.fromLocationData.address = obj.address
        add_data.fromLocationData.name = obj.stationName
        add_data.fromLocationData.id = obj.id
        add_data.fromLocationData.lnglat = obj.lngLat
        add_data.fromLocationData.tel = obj.hotelLinkPhone


    } else if (item == 2) {
        let data = add_data.toLocation
        let obj = {}
        for (let i = 0; i < getStationList_Data2.value.length; i++) {
            if (data == getStationList_Data2.value[i].stationName) {
                obj = getStationList_Data2.value[i]
            }

        }
        add_data.toLocation = obj.stationName
        add_data.toLocationData.address = obj.address
        add_data.toLocationData.name = obj.stationName
        add_data.toLocationData.id = obj.id
        add_data.toLocationData.lnglat = obj.lngLat
        add_data.toLocationData.tel = obj.hotelLinkPhone

    } else {
        return ElMessage({
            message: '地址错误',
            type: 'warning',
        })
    }
}
const select_Btn2 = (item) => {

    if (item == 1) {
        let data = add_data.returnOrder.fromLocation
        let obj = {}
        for (let i = 0; i < getStationList_Data2.value.length; i++) {
            if (data == getStationList_Data2.value[i].stationName) {
                obj = getStationList_Data2.value[i]
            }

        }
        add_data.returnOrder.fromLocation = obj.stationName
        add_data.returnOrder.fromLocationData.address = obj.address
        add_data.returnOrder.fromLocationData.name = obj.stationName
        add_data.returnOrder.fromLocationData.id = obj.id
        add_data.returnOrder.fromLocationData.lnglat = obj.lngLat
        add_data.returnOrder.fromLocationData.tel = obj.hotelLinkPhone

    } else if (item == 2) {
        let data = add_data.returnOrder.toLocation
        let obj = {}
        for (let i = 0; i < getStationList_Data2.value.length; i++) {
            if (data == getStationList_Data2.value[i].stationName) {
                obj = getStationList_Data2.value[i]
            }

        }
        add_data.returnOrder.toLocation = obj.stationName
        add_data.returnOrder.toLocationData.address = obj.address
        add_data.returnOrder.toLocationData.name = obj.stationName
        add_data.returnOrder.toLocationData.id = obj.id
        add_data.returnOrder.toLocationData.lnglat = obj.lngLat
        add_data.returnOrder.toLocationData.tel = obj.hotelLinkPhone
    } else {
        return ElMessage({
            message: '地址错误',
            type: 'warning',
        })
    }
}
// 地图选择

const myMap = ref('')
const map_address = ref('')
const map_address_list = ref([])
const map_value = ref({})
const marker = ref('')
const map_off = ref(false)
const address_map_off = ref('') // 1:出发地 2：目的地
const map_off_btn = (e) => {
    if (e == 1) {
        address_map_off.value = '1'
        map_address_name.value = ''
        map2_off.value = true
    } else if (e == 2) {
        address_map_off.value = '2'
        map_address_name.value = ''
        map2_off.value = true
    } else if (e == 3) {
        address_map_off.value = '3'
        map_address_name.value = ''
        map2_off.value = true
    } else if (e == 4) {
        address_map_off.value = '4'
        map_address_name.value = ''
        map2_off.value = true
    }
}

const map_off_btn2 = (e) => {
    address_map_off.value = e
    // 地图
    window._AMapSecurityConfig = {
        securityJsCode: securityJsCode,
    }
    // 首次加载
    AMapLoader.load({
        key: key,
        version: '2.0',
        plugins: ['AMap.Driving', 'AMap.Geolocation', 'AMap.Scale', 'AMap.AutoComplete', 'AMap.PlaceSearch'],
    }).then((AMap) => {
        // 初始化-地图对象
        myMap.value = new AMap.Map('myMap', { zoom: 10, center: [104.065861, 30.657401] });

    }).catch(err => { console.log('高德地图加载失败：', err); });

    map_address.value = ''
    map_value.value = {}
    map_address_list.value = ''
    map2_off.value = false
    map_off.value = true
}
const map_change = () => {


    findMapPointList({
        city: '成都',
        isFindSta: '0',
        keywords: map_address.value,

    }).then(res => {
        map_address_list.value = res.data.slice(0, 5)
    })
}

const map_list_btn = (e) => {
    map_address.value = e.area + '-' + e.name + '-' + e.address
    map_value.value = e
    let lnglat = [e.lnglat.split(',')[0], e.lnglat.split(',')[1]]
    myMap.value.panTo(lnglat);
    if (marker.value) {
        myMap.value.remove(marker.value);
    }
    myMap.value.setFitView();
    marker.value = new AMap.Marker({
        map: myMap.value,
        position: lnglat,
    });
    myMap.value.setFitView();
    myMap.value.add(marker.value);

}

const map_list_btn2 = (e) => {
    if (address_map_off.value == '1') {
        // 出发地
        let data = e.stationName
        let obj = {}
        for (let i = 0; i < getStationList_Data2.value.length; i++) {
            if (data == getStationList_Data2.value[i].stationName) {
                obj = getStationList_Data2.value[i]
            }

        }
        add_data.fromLocation = obj.stationName
        add_data.fromLocationData.address = obj.address
        add_data.fromLocationData.name = obj.stationName
        add_data.fromLocationData.id = obj.id
        add_data.fromLocationData.lnglat = obj.lngLat
        add_data.fromLocationData.tel = obj.hotelLinkPhone
    } else if (address_map_off.value == '2') {
        // 目的地
        let data = e.stationName
        let obj = {}
        for (let i = 0; i < getStationList_Data2.value.length; i++) {
            if (data == getStationList_Data2.value[i].stationName) {
                obj = getStationList_Data2.value[i]
            }

        }
        add_data.toLocation = obj.stationName
        add_data.toLocationData.address = obj.address
        add_data.toLocationData.name = obj.stationName
        add_data.toLocationData.id = obj.id
        add_data.toLocationData.lnglat = obj.lngLat
        add_data.toLocationData.tel = obj.hotelLinkPhone
    } else if (address_map_off.value == '3') {
        // 出发地
        let data = e.stationName
        let obj = {}
        for (let i = 0; i < getStationList_Data2.value.length; i++) {
            if (data == getStationList_Data2.value[i].stationName) {
                obj = getStationList_Data2.value[i]
            }

        }
        add_data.returnOrder.fromLocation = obj.stationName
        add_data.returnOrder.fromLocationData.address = obj.address
        add_data.returnOrder.fromLocationData.name = obj.stationName
        add_data.returnOrder.fromLocationData.id = obj.id
        add_data.returnOrder.fromLocationData.lnglat = obj.lngLat
        add_data.returnOrder.fromLocationData.tel = obj.hotelLinkPhone
    } else if (address_map_off.value == '4') {
        // 目的地
        let data = e.stationName
        let obj = {}
        for (let i = 0; i < getStationList_Data2.value.length; i++) {
            if (data == getStationList_Data2.value[i].stationName) {
                obj = getStationList_Data2.value[i]
            }

        }
        add_data.returnOrder.toLocation = obj.stationName
        add_data.returnOrder.toLocationData.address = obj.address
        add_data.returnOrder.toLocationData.name = obj.stationName
        add_data.returnOrder.toLocationData.id = obj.id
        add_data.returnOrder.toLocationData.lnglat = obj.lngLat
        add_data.returnOrder.toLocationData.tel = obj.hotelLinkPhone
    } else {
        return ElMessage({
            message: '地址错误',
            type: 'warning',
        })
    }
    address_map_off.value = ''
    map_address_name.value = ''
    map2_off.value = false

}

const map2_off = ref(false)
const map_address_name = ref('')


const map_ok_btn = () => {
    if (address_map_off.value == '1') {
        // 出发地
        add_data.fromLocation = map_value.value.name
        add_data.fromLocationData = map_value.value
    } else if (address_map_off.value == '2') {
        // 目的地
        add_data.toLocation = map_value.value.name
        add_data.toLocationData = map_value.value
    } else if (address_map_off.value == '3') {
        // 出发地
        add_data.returnOrder.fromLocation = map_value.value.name
        add_data.returnOrder.fromLocationData = map_value.value
    } else if (address_map_off.value == '4') {
        // 目的地
        add_data.returnOrder.toLocation = map_value.value.name
        add_data.returnOrder.toLocationData = map_value.value
    } else if (passing_points_off.value == '1') {
        passing_points_list.value.push(map_value.value)
        passing_points_index.value += 1
    } else if (passing_points_off.value == '2') {
        passing_points_list2.value.push(map_value.value)
        passing_points_index2.value += 1
    }

    passing_points_off.value = ''
    address_map_off.value = ''
    map_address.value = ''
    map_value.value = {}
    map_address_list.value = []
    map_off.value = false

}
// 添加途径点
const passing_points_list = ref([])
const passing_points_index = ref(0)
const passing_points_off = ref('')
const passing_points_list2 = ref([])
const passing_points_index2 = ref(0)
const add_passing_points = (e) => {
    if (e == 1) {

        if (passing_points_index.value > 4) {
            return ElMessage({
                message: '火车的途径点最多添加5个',
                type: 'warning',
            })
        }
        passing_points_off.value = '1'
    } else if (e == 2) {
        if (passing_points_index2.value > 4) {
            return ElMessage({
                message: '火车的途径点最多添加5个',
                type: 'warning',
            })
        }
        passing_points_off.value = '2'
    }
    // 地图
    window._AMapSecurityConfig = {
        securityJsCode: securityJsCode,
    }
    // 首次加载
    AMapLoader.load({
        key: key,
        version: '2.0',
        plugins: ['AMap.Driving', 'AMap.Geolocation', 'AMap.Scale', 'AMap.AutoComplete', 'AMap.PlaceSearch'],
    }).then((AMap) => {
        // 初始化-地图对象
        myMap.value = new AMap.Map('myMap', { zoom: 10, center: [104.065861, 30.657401] });
    }).catch(err => { console.log('高德地图加载失败：', err); });
    map_off.value = true
}
const passing_points_index_delbtn = (index) => {
    passing_points_index.value -= 1
    passing_points_list.value.splice(index, 1)
}
const passing_points_index_delbtn2 = (index) => {
    passing_points_index2.value -= 1
    passing_points_list2.value.splice(index, 1)
}
//#endregion
//#region 包车拼车
const aircraft_radio = ref('包车')
const aircraft_radio2 = ref('包车')
const chartered_bus_off = ref(false) // 包车拼车开关
const chartered_bus_off2 = ref(false)
const aircraft_connect_change1 = (e) => {
    aircraft_radio.value = '包车'
    chartered_bus_off.value = false
    if (!e) {
        add_data.returnOrder.fromLocation = ''
        add_data.returnOrder.toLocation = ''

    }


    if (e == '其他位置地图选址') {
        map_off_btn(1)
    }

}
const aircraft_connect_change2 = (e) => {
    aircraft_radio.value = '包车'
    chartered_bus_off.value = false
    if (!e) {
        add_data.returnOrder.fromLocation = ''
        add_data.returnOrder.toLocation = ''

    }


    if (e == '其他位置地图选址') {
        map_off_btn(2)
    }

}

const aircraft_connect_change3 = (e) => {
    aircraft_radio2.value = '包车'

    if (e == '其他位置地图选址') {
        map_off_btn(3)
    }
}
const aircraft_connect_change4 = (e) => {
    aircraft_radio2.value = '包车'

    if (e == '其他位置地图选址') {
        map_off_btn(4)
    }
}
const radio_group_change = () => {
    add_data.carConfig = ''
    add_data.price = ''
    add_data.ensureMoney = ''
    add_data.regularCarMoney = ''
    add_data.needSeats = '0'
    add_data.priceNeedSeats = ''
    if (aircraft_radio.value == '拼车') {
        add_cusName_list.value = []
        add_cusName_index.value = 0
        passing_points_list.value = []
        passing_points_index.value = 0
    }
}
const radio_group_change2 = () => {
    add_data.returnOrder.carConfig = ''
    add_data.returnOrder.price = ''
    add_data.returnOrder.ensureMoney = ''
    add_data.returnOrder.regularCarMoney = ''
    add_data.returnOrder.needSeats = '0'
    add_data.returnOrder.priceNeedSeats = ''

    if (aircraft_radio2.value == '拼车') {
        add_cusName_list2.value = []
        add_cusName_index2.value = 0
        passing_points_list2.value = []
        passing_points_index2.value = 0
    }
}
//#endregion
//#region 指定车型
const getCarConfigurationType_list = ref([])
const getCarConfigurationType_list2 = ref([])
const needSeats_change = () => {
    add_data.carConfig = ''
    add_data.price = ''
    add_data.ensureMoney = ''
    add_data.regularCarMoney = ''
    let stationListId = null

    if (add_data.fromLocation && add_data.toLocation) {
        if (!add_data.fromLocation.includes('停车') && add_data.fromLocation.includes('站') && !add_data.fromLocation.includes('地铁')) {
            if (add_data.fromLocation.includes('站')) {
                for (let i = 0; i < aircraft_list2.value.length; i++) {
                    if (add_data.fromLocation == aircraft_list2.value[i].station_name) {
                        stationListId = aircraft_list2.value[i].id

                    }

                }
            } else {
                return ElMessage({
                    message: '出发地址有误！',
                    type: 'warning',
                })
            }

        } else if (!add_data.toLocation.includes('停车') && add_data.toLocation.includes('站') && !add_data.toLocation.includes('地铁')) {
            if (add_data.toLocation.includes('站')) {
                for (let i = 0; i < aircraft_list2.value.length; i++) {
                    if (add_data.toLocation == aircraft_list2.value[i].station_name) {
                        stationListId = aircraft_list2.value[i].id

                    }

                }
            } else {
                return ElMessage({
                    message: '目的地址有误！',
                    type: 'warning',
                })
            }
        } else {
            return ElMessage({
                message: '地址有误！',
                type: 'warning',
            })
        }

    } else {
        add_data.needSeats = '0'
        add_data.priceNeedSeats = ''
        return ElMessage({
            message: '请先填写出发地址和目的地址！',
            type: 'warning',
        })
    }
    if (!add_data.personNum) {
        add_data.needSeats = '0'
        add_data.priceNeedSeats = ''
        return ElMessage({
            message: '请先填写乘车人数！',
            type: 'warning',
        })
    }

    if (add_data.needSeats > 0) {
        if (add_data.needSeats < Number(add_data.personNum) + 1) {
            add_data.needSeats = '0'
            add_data.priceNeedSeats = ''
            return ElMessage({
                message: '指定车型少于乘车人＋驾驶员，请重新选择',
                type: 'warning',
            })
        } else {
            let luser = JSON.parse(localStorage.getItem("luser"))
            let luser_companyNum = luser.companyNum
            getCarConfigurationType({
                stationListId: stationListId,
                addWay: '1',
                seats: add_data.needSeats,
                companyNum: luser_companyNum,
                orderType: '1',

            }).then(res => {

                if (res.code == 1) {
                    getCarConfigurationType_list.value = res.data
                } else {
                    add_data.needSeats = '0'
                    add_data.priceNeedSeats = ''
                    return ElMessage({
                        message: res.msg,
                        type: 'warning',
                    })
                }
            })
        }
    }
}
const needSeats_change2 = () => {
    add_data.returnOrder.carConfig = ''
    add_data.returnOrder.price = ''
    add_data.returnOrder.ensureMoney = ''
    add_data.returnOrder.regularCarMoney = ''
    let stationListId = null

    if (add_data.returnOrder.fromLocation && add_data.returnOrder.toLocation) {
        if (!add_data.returnOrder.fromLocation.includes('停车') && add_data.returnOrder.fromLocation.includes('站') && !add_data.returnOrder.fromLocation.includes('地铁')) {
            if (add_data.returnOrder.fromLocation.includes('站')) {
                for (let i = 0; i < aircraft_list2.value.length; i++) {
                    if (add_data.returnOrder.fromLocation == aircraft_list2.value[i].station_name) {
                        stationListId = aircraft_list2.value[i].id

                    }

                }
            } else {
                return ElMessage({
                    message: '出发地址有误！',
                    type: 'warning',
                })
            }

        } else if (!add_data.returnOrder.toLocation.includes('停车') && add_data.returnOrder.toLocation.includes('站') && !add_data.returnOrder.toLocation.includes('地铁')) {
            if (add_data.returnOrder.toLocation.includes('站')) {
                for (let i = 0; i < aircraft_list2.value.length; i++) {
                    if (add_data.returnOrder.toLocation == aircraft_list2.value[i].station_name) {
                        stationListId = aircraft_list2.value[i].id

                    }

                }
            } else {
                return ElMessage({
                    message: '目的地址有误！',
                    type: 'warning',
                })
            }
        } else {
            return ElMessage({
                message: '地址有误！',
                type: 'warning',
            })
        }

    } else {
        add_data.returnOrder.needSeats = '0'
        add_data.returnOrder.priceNeedSeats = ''
        return ElMessage({
            message: '请先填写出发地址和目的地址！',
            type: 'warning',
        })
    }
    if (!add_data.returnOrder.personNum) {
        add_data.returnOrder.needSeats = '0'
        add_data.returnOrder.priceNeedSeats = ''
        return ElMessage({
            message: '请先填写乘车人数！',
            type: 'warning',
        })
    }

    if (add_data.returnOrder.needSeats > 0) {
        if (add_data.returnOrder.needSeats < Number(add_data.returnOrder.personNum) + 1) {
            add_data.returnOrder.needSeats = '0'
            add_data.returnOrder.priceNeedSeats = ''
            return ElMessage({
                message: '指定车型少于乘车人＋驾驶员，请重新选择',
                type: 'warning',
            })
        } else {
            let luser = JSON.parse(localStorage.getItem("luser"))
            let luser_companyNum = luser.companyNum
            getCarConfigurationType({
                stationListId: stationListId,
                addWay: '1',
                seats: add_data.returnOrder.needSeats,
                companyNum: luser_companyNum,
                orderType: '1',
            }).then(res => {

                if (res.code == 1) {
                    getCarConfigurationType_list2.value = res.data
                } else {
                    add_data.returnOrder.needSeats = '0'
                    add_data.returnOrder.priceNeedSeats = ''
                    return ElMessage({
                        message: res.msg,
                        type: 'warning',
                    })
                }
            })
        }
    }
}
//#endregion
//#region 自动计算费用
const price_btn = (e) => {
    // e == 1顺程 e==2返程
    if (e == 1) {
        if (!add_data.startTime) {
            return ElMessage({
                message: '请选择出发时间',
                type: 'warning',
            })
        } else if (!add_data.fromLocation) {
            return ElMessage({
                message: '请选择出发地址',
                type: 'warning',
            })
        } else if (!add_data.toLocation) {
            return ElMessage({
                message: '请选择目的地址',
                type: 'warning',
            })
        } else if (!add_data.personNum) {
            return ElMessage({
                message: '请输入预约人数',
                type: 'warning',
            })
        } else if (time_number1.value.length != 4) {
            return ElMessage({
                message: '时间不对请检查',
                type: 'warning',
            })
        } else if (!add_data.userId) {
            return ElMessage({
                message: '请检查客户',
                type: 'warning',
            })
        }

        if (add_data.fromLocation == '成都北站') {
            add_data.routeSimpleName = '接北站'
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.fromLocation == aircraft_list2.value[i].station_name) {
                    add_data.fromLocationId = aircraft_list2.value[i].id
                    add_data.fromLocationData.address = aircraft_list2.value[i].station_name
                    add_data.fromLocationData.area = aircraft_list2.value[i].station_name
                    add_data.fromLocationData.id = aircraft_list2.value[i].id
                    add_data.fromLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
        } else if (add_data.fromLocation == '成都西站') {
            add_data.routeSimpleName = '接西站'
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.fromLocation == aircraft_list2.value[i].station_name) {
                    add_data.fromLocationId = aircraft_list2.value[i].id
                    add_data.fromLocationData.address = aircraft_list2.value[i].station_name
                    add_data.fromLocationData.area = aircraft_list2.value[i].station_name
                    add_data.fromLocationData.id = aircraft_list2.value[i].id
                    add_data.fromLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
        } else if (add_data.fromLocation == '成都南站') {
            add_data.routeSimpleName = '接南站'
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.fromLocation == aircraft_list2.value[i].station_name) {
                    add_data.fromLocationId = aircraft_list2.value[i].id
                    add_data.fromLocationData.address = aircraft_list2.value[i].station_name
                    add_data.fromLocationData.area = aircraft_list2.value[i].station_name
                    add_data.fromLocationData.id = aircraft_list2.value[i].id
                    add_data.fromLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
        } else if (add_data.fromLocation == '成都东站') {
            add_data.routeSimpleName = '接东站'
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.fromLocation == aircraft_list2.value[i].station_name) {
                    add_data.fromLocationId = aircraft_list2.value[i].id
                    add_data.fromLocationData.address = aircraft_list2.value[i].station_name
                    add_data.fromLocationData.area = aircraft_list2.value[i].station_name
                    add_data.fromLocationData.id = aircraft_list2.value[i].id
                    add_data.fromLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
        } else if (add_data.toLocation == '成都北站') {
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.toLocation == aircraft_list2.value[i].station_name) {
                    add_data.toLocationId = aircraft_list2.value[i].id
                    add_data.toLocationData.address = aircraft_list2.value[i].station_name
                    add_data.toLocationData.area = aircraft_list2.value[i].station_name
                    add_data.toLocationData.id = aircraft_list2.value[i].id
                    add_data.toLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
            add_data.routeSimpleName = '送北站'
        } else if (add_data.toLocation == '成都西站') {
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.toLocation == aircraft_list2.value[i].station_name) {
                    add_data.toLocationId = aircraft_list2.value[i].id
                    add_data.toLocationData.address = aircraft_list2.value[i].station_name
                    add_data.toLocationData.area = aircraft_list2.value[i].station_name
                    add_data.toLocationData.id = aircraft_list2.value[i].id
                    add_data.toLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
            add_data.routeSimpleName = '送西站'
        } else if (add_data.toLocation == '成都南站') {
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.toLocation == aircraft_list2.value[i].station_name) {
                    add_data.toLocationId = aircraft_list2.value[i].id
                    add_data.toLocationData.address = aircraft_list2.value[i].station_name
                    add_data.toLocationData.area = aircraft_list2.value[i].station_name
                    add_data.toLocationData.id = aircraft_list2.value[i].id
                    add_data.toLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
            add_data.routeSimpleName = '送南站'
        } else if (add_data.toLocation == '成都东站') {
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.toLocation == aircraft_list2.value[i].station_name) {
                    add_data.toLocationId = aircraft_list2.value[i].id
                    add_data.toLocationData.address = aircraft_list2.value[i].station_name
                    add_data.toLocationData.area = aircraft_list2.value[i].station_name
                    add_data.toLocationData.id = aircraft_list2.value[i].id
                    add_data.toLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
            add_data.routeSimpleName = '送东站'
        } else {
            return ElMessage({
                message: '行程简称有误！',
                type: 'warning',
            })
        }
        if (aircraft_radio.value == '包车') {
            add_data.type = '1'
        } else if (aircraft_radio.value == '拼车') {
            add_data.type = '0'
        }

        for (let i = 0; i < cusOptions2.value.length; i++) {
            if (add_data.userId == cusOptions2.value[i].userId) {
                add_data.useCarCompanyName = cusOptions2.value[i].cusCompanyName
            }
        }

        for (let i = 0; i < getAllDutyOfCustom_list2.value.length; i++) {
            if (add_data.useCarDutyUserId == getAllDutyOfCustom_list2.value[i].ftUserId) {
                add_data.useCarDutyInfo = getAllDutyOfCustom_list2.value[i].ftUserId + '-' + getAllDutyOfCustom_list2.value[i].realName + '-' + getAllDutyOfCustom_list2.value[i].loginPhone
            }
        }

        for (let i = 0; i < getServiceMans_list2.value.length; i++) {
            if (add_data.serviceMan == getServiceMans_list2.value[i].ftUserId) {
                add_data.serviceMan = getServiceMans_list2.value[i].ftUserId + '-' + getServiceMans_list2.value[i].realName + '-' + getServiceMans_list2.value[i].loginPhone
            }
        }
        add_data.points = passing_points_list.value
        let hours = time_number1.value.substring(0, 2);
        let minutes = time_number1.value.substring(2);
        // 重新格式化为 'hh:mm'
        let formattedValue = `${hours}:${minutes}:00`;
        let startTime = add_data.startTime + ' ' + formattedValue

        if (!add_data.flightNum) {
            if (add_data.routeSimpleName.includes('接')) {
                add_data.landDate = startTime
            } else if (add_data.routeSimpleName.includes('送')) {
                add_data.flightDate = startTime
            }
        }

        let ps = {
            flightDate: add_data.flightDate,
            flightNum: add_data.flightNum,
            fromLocation: add_data.fromLocation,
            fromLocationData: add_data.fromLocationData,
            fromLocationId: add_data.fromLocationId,
            landDate: add_data.landDate,
            needSeats: add_data.needSeats,
            priceNeedSeats: add_data.priceNeedSeats,
            carConfig: add_data.carConfig,
            personNum: add_data.personNum,
            routeSimpleName: add_data.routeSimpleName,
            startTime: startTime,
            toLocation: add_data.toLocation,
            toLocationData: add_data.toLocationData,
            toLocationId: add_data.toLocationId,
            userId: add_data.userId,
            useCarDutyUserId: add_data.useCarDutyUserId,
            useCarCompanyName: add_data.useCarCompanyName,
            useCarDutyInfo: add_data.useCarDutyInfo,
            serviceMan: add_data.serviceMan,
            type: add_data.type,
            points: add_data.points,
            id: add_data.id,

        }
        if (ps.needSeats == '0' || ps.needSeats == '') {
            ps.needSeats = null
        }
        if (ps.priceNeedSeats == '0' || ps.priceNeedSeats == '') {
            ps.priceNeedSeats = null
        }


        getPrice(ps).then(res => {

            if (res.code == 1) {

                add_data.serviceMan = add_data.serviceMan.split('-')[0]
                add_data.price = res.data.price
                add_data.ensureMoney = res.data.ensureMoney
                add_data.regularCarMoney = res.data.regularCarMoney
                add_data.priceNeedSeats = res.data.priceNeedSeats

            } else {
                add_data.serviceMan = add_data.serviceMan.split('-')[0]
                add_data.price = ''
                add_data.ensureMoney = ''
                add_data.regularCarMoney = ''
                return ElMessage({
                    message: res.msg,
                    type: 'warning',
                })
            }
        })
    } else if (e == 2) {
        if (add_data.returnOrder.fromLocation == '成都北站') {
            add_data.returnOrder.routeSimpleName = '接北站'
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.returnOrder.fromLocation == aircraft_list2.value[i].station_name) {
                    add_data.returnOrder.fromLocationId = aircraft_list2.value[i].id
                    add_data.returnOrder.fromLocationData.address = aircraft_list2.value[i].station_name
                    add_data.returnOrder.fromLocationData.area = aircraft_list2.value[i].station_name
                    add_data.returnOrder.fromLocationData.id = aircraft_list2.value[i].id
                    add_data.returnOrder.fromLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
        } else if (add_data.returnOrder.fromLocation == '成都西站') {
            add_data.returnOrder.routeSimpleName = '接西站'
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.returnOrder.fromLocation == aircraft_list2.value[i].station_name) {
                    add_data.returnOrder.fromLocationId = aircraft_list2.value[i].id
                    add_data.returnOrder.fromLocationData.address = aircraft_list2.value[i].station_name
                    add_data.returnOrder.fromLocationData.area = aircraft_list2.value[i].station_name
                    add_data.returnOrder.fromLocationData.id = aircraft_list2.value[i].id
                    add_data.returnOrder.fromLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
        } else if (add_data.returnOrder.fromLocation == '成都南站') {
            add_data.returnOrder.routeSimpleName = '接南站'
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.returnOrder.fromLocation == aircraft_list2.value[i].station_name) {
                    add_data.returnOrder.fromLocationId = aircraft_list2.value[i].id
                    add_data.returnOrder.fromLocationData.address = aircraft_list2.value[i].station_name
                    add_data.returnOrder.fromLocationData.area = aircraft_list2.value[i].station_name
                    add_data.returnOrder.fromLocationData.id = aircraft_list2.value[i].id
                    add_data.returnOrder.fromLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
        } else if (add_data.returnOrder.fromLocation == '成都东站') {
            add_data.returnOrder.routeSimpleName = '接东站'
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.returnOrder.fromLocation == aircraft_list2.value[i].station_name) {
                    add_data.returnOrder.fromLocationId = aircraft_list2.value[i].id
                    add_data.returnOrder.fromLocationData.address = aircraft_list2.value[i].station_name
                    add_data.returnOrder.fromLocationData.area = aircraft_list2.value[i].station_name
                    add_data.returnOrder.fromLocationData.id = aircraft_list2.value[i].id
                    add_data.returnOrder.fromLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
        } else if (add_data.returnOrder.toLocation == '成都北站') {
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.returnOrder.toLocation == aircraft_list2.value[i].station_name) {
                    add_data.returnOrder.toLocationId = aircraft_list2.value[i].id
                    add_data.returnOrder.toLocationData.address = aircraft_list2.value[i].station_name
                    add_data.returnOrder.toLocationData.area = aircraft_list2.value[i].station_name
                    add_data.returnOrder.toLocationData.id = aircraft_list2.value[i].id
                    add_data.returnOrder.toLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
            add_data.returnOrder.routeSimpleName = '送北站'
        } else if (add_data.returnOrder.toLocation == '成都西站') {
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.returnOrder.toLocation == aircraft_list2.value[i].station_name) {
                    add_data.returnOrder.toLocationId = aircraft_list2.value[i].id
                    add_data.returnOrder.toLocationData.address = aircraft_list2.value[i].station_name
                    add_data.returnOrder.toLocationData.area = aircraft_list2.value[i].station_name
                    add_data.returnOrder.toLocationData.id = aircraft_list2.value[i].id
                    add_data.returnOrder.toLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
            add_data.returnOrder.routeSimpleName = '送西站'
        } else if (add_data.returnOrder.toLocation == '成都南站') {
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.returnOrder.toLocation == aircraft_list2.value[i].station_name) {
                    add_data.returnOrder.toLocationId = aircraft_list2.value[i].id
                    add_data.returnOrder.toLocationData.address = aircraft_list2.value[i].station_name
                    add_data.returnOrder.toLocationData.area = aircraft_list2.value[i].station_name
                    add_data.returnOrder.toLocationData.id = aircraft_list2.value[i].id
                    add_data.returnOrder.toLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
            add_data.returnOrder.routeSimpleName = '送南站'
        } else if (add_data.returnOrder.toLocation == '成都东站') {
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.returnOrder.toLocation == aircraft_list2.value[i].station_name) {
                    add_data.returnOrder.toLocationId = aircraft_list2.value[i].id
                    add_data.returnOrder.toLocationData.address = aircraft_list2.value[i].station_name
                    add_data.returnOrder.toLocationData.area = aircraft_list2.value[i].station_name
                    add_data.returnOrder.toLocationData.id = aircraft_list2.value[i].id
                    add_data.returnOrder.toLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
            add_data.returnOrder.routeSimpleName = '送东站'
        } else {
            return ElMessage({
                message: '行程简称有误！',
                type: 'warning',
            })
        }
        if (aircraft_radio2.value == '包车') {
            add_data.returnOrder.type = '1'
        } else if (aircraft_radio2.value == '拼车') {
            add_data.returnOrder.type = '0'
        }

        for (let i = 0; i < cusOptions2.value.length; i++) {
            if (add_data.userId == cusOptions2.value[i].userId) {
                add_data.returnOrder.useCarCompanyName = cusOptions2.value[i].cusCompanyName
                add_data.returnOrder.userId = add_data.userId
            }
        }

        for (let i = 0; i < getAllDutyOfCustom_list2.value.length; i++) {
            if (add_data.useCarDutyUserId == getAllDutyOfCustom_list2.value[i].ftUserId) {
                add_data.returnOrder.useCarDutyInfo = getAllDutyOfCustom_list2.value[i].ftUserId + '-' + getAllDutyOfCustom_list2.value[i].realName + '-' + getAllDutyOfCustom_list2.value[i].loginPhone
                add_data.returnOrder.useCarDutyUserId = add_data.useCarDutyUserId
            }
        }

        for (let i = 0; i < getServiceMans_list2.value.length; i++) {
            if (add_data.serviceMan == getServiceMans_list2.value[i].ftUserId) {
                add_data.returnOrder.serviceMan = getServiceMans_list2.value[i].ftUserId + '-' + getServiceMans_list2.value[i].realName + '-' + getServiceMans_list2.value[i].loginPhone
            }
        }
        add_data.returnOrder.points = passing_points_list2.value
        let hours = time_number2.value.substring(0, 2);
        let minutes = time_number2.value.substring(2);
        // 重新格式化为 'hh:mm'
        let formattedValue = `${hours}:${minutes}:00`;
        let startTime = add_data.returnOrder.startTime + ' ' + formattedValue

        if (!add_data.returnOrder.flightNum) {
            if (add_data.returnOrder.routeSimpleName.includes('接')) {
                add_data.returnOrder.landDate = startTime
            } else if (add_data.returnOrder.routeSimpleName.includes('送')) {
                add_data.returnOrder.flightDate = startTime
            }
        }
        if (!add_data.returnOrder.startTime) {
            return ElMessage({
                message: '请选择出发时间',
                type: 'warning',
            })
        } else if (!add_data.returnOrder.fromLocation) {
            return ElMessage({
                message: '请选择出发地址',
                type: 'warning',
            })
        } else if (!add_data.returnOrder.toLocation) {
            return ElMessage({
                message: '请选择目的地址',
                type: 'warning',
            })
        } else if (!add_data.returnOrder.personNum) {
            return ElMessage({
                message: '请输入预约人数',
                type: 'warning',
            })
        } else if (time_number2.value.length != 4) {
            return ElMessage({
                message: '时间不对请检查',
                type: 'warning',
            })
        } else if (!add_data.returnOrder.userId) {
            return ElMessage({
                message: '请检查客户',
                type: 'warning',
            })
        }

        let ps = {
            flightDate: add_data.returnOrder.flightDate,
            flightNum: add_data.returnOrder.flightNum,
            fromLocation: add_data.returnOrder.fromLocation,
            fromLocationData: add_data.returnOrder.fromLocationData,
            fromLocationId: add_data.returnOrder.fromLocationId,
            landDate: add_data.returnOrder.landDate,
            needSeats: add_data.returnOrder.needSeats,
            priceNeedSeats: add_data.returnOrder.priceNeedSeats,
            carConfig: add_data.returnOrder.carConfig,
            personNum: add_data.returnOrder.personNum,
            routeSimpleName: add_data.returnOrder.routeSimpleName,
            startTime: startTime,
            toLocation: add_data.returnOrder.toLocation,
            toLocationData: add_data.returnOrder.toLocationData,
            toLocationId: add_data.returnOrder.toLocationId,
            userId: add_data.returnOrder.userId,
            useCarDutyUserId: add_data.returnOrder.useCarDutyUserId,
            useCarCompanyName: add_data.returnOrder.useCarCompanyName,
            useCarDutyInfo: add_data.returnOrder.useCarDutyInfo,
            serviceMan: add_data.returnOrder.serviceMan,
            type: add_data.returnOrder.type,
            points: add_data.returnOrder.points,
            id: add_data.returnOrder.id,

        }
        if (ps.needSeats == '0' || ps.needSeats == '') {
            ps.needSeats = null
        }
        if (ps.priceNeedSeats == '0' || ps.priceNeedSeats == '') {
            ps.priceNeedSeats = null
        }


        getPrice(ps).then(res => {

            if (res.code == 1) {

                add_data.returnOrder.serviceMan = add_data.returnOrder.serviceMan.split('-')[0]
                add_data.returnOrder.price = res.data.price
                add_data.returnOrder.ensureMoney = res.data.ensureMoney
                add_data.returnOrder.regularCarMoney = res.data.regularCarMoney
                add_data.returnOrder.priceNeedSeats = res.data.priceNeedSeats

            } else {
                add_data.returnOrder.serviceMan = add_data.returnOrder.serviceMan.split('-')[0]
                add_data.returnOrder.price = ''
                add_data.returnOrder.ensureMoney = ''
                add_data.returnOrder.regularCarMoney = ''
                return ElMessage({
                    message: res.msg,
                    type: 'warning',
                })
            }
        })
    } else {
        return ElMessage({
            message: '返程计算价格有误',
            type: 'warning',
        })
    }

}
//#endregion
//#region 添加联系人
const add_cusName_list = ref([])
const add_cusName_index = ref(0)
const add_cusName_list2 = ref([])
const add_cusName_index2 = ref(0)

const add_cusName_index_delbtn = (index) => {
    add_cusName_index.value -= 1
    add_cusName_list.value.splice(index, 1)

}
const add_cusName_index_delbtn2 = (index) => {
    add_cusName_index2.value -= 1
    add_cusName_list2.value.splice(index, 1)

}
const add_cusName_btn = (e) => {
    let p = {
        name: '',
        mobile: '',
    }
    if (e == 1) {
        add_cusName_list.value.push(p)
        add_cusName_index.value += 1
    } else if (e == 2) {
        add_cusName_list2.value.push(p)
        add_cusName_index2.value += 1
    }

}
//#endregion
//#region 返程
const isReturnAdd_change = () => {
    let data = add_data.isReturnAdd

    if (!add_data.startTime) {
        add_data.isReturnAdd = 'false'
        return ElMessage({
            message: '请选择顺程出发时间',
            type: 'warning',
        })
    } else if (!add_data.fromLocation) {
        add_data.isReturnAdd = 'false'
        return ElMessage({
            message: '请选择顺程出发地址',
            type: 'warning',
        })
    } else if (!add_data.toLocation) {
        add_data.isReturnAdd = 'false'
        return ElMessage({
            message: '请选择顺程目的地址',
            type: 'warning',
        })
    } else if (time_number1.value.length != 4) {
        add_data.isReturnAdd = 'false'
        return ElMessage({
            message: '顺程时间不对请检查',
            type: 'warning',
        })
    } else if (!add_data.userId) {
        add_data.isReturnAdd = 'false'
        return ElMessage({
            message: '请选择客户',
            type: 'warning',
        })
    }
    if (data == 'true') {
        add_data.returnOrder.cusMobile = add_data.cusMobile
        add_data.returnOrder.cusName = add_data.cusName
        add_data.returnOrder.days = add_data.days
        add_data.returnOrder.endTime = ''
        add_data.returnOrder.flightDate = add_data.landDate
        add_data.returnOrder.flightNum = add_data.flightNum
        add_data.returnOrder.flightTime = ''
        add_data.returnOrder.fromLocation = add_data.toLocation
        add_data.returnOrder.fromLocationId = add_data.toLocationId
        add_data.returnOrder.fromLocationData.address = add_data.toLocationData.address
        add_data.returnOrder.fromLocationData.area = add_data.toLocationData.area
        add_data.returnOrder.fromLocationData.id = add_data.toLocationData.id
        add_data.returnOrder.fromLocationData.isSta = add_data.toLocationData.isSta
        add_data.returnOrder.fromLocationData.lnglat = add_data.toLocationData.lnglat
        add_data.returnOrder.fromLocationData.name = add_data.toLocationData.name
        add_data.returnOrder.fromLocationData.tel = add_data.toLocationData.tel
        add_data.returnOrder.fromLocationData.type = add_data.toLocationData.type
        add_data.returnOrder.landDate = add_data.flightDate
        add_data.returnOrder.needSeats = add_data.needSeats
        add_data.returnOrder.priceNeedSeats = add_data.priceNeedSeats
        add_data.returnOrder.carConfig = add_data.carConfig
        add_data.returnOrder.personNum = add_data.personNum
        add_data.returnOrder.receiveMsg = add_data.receiveMsg
        add_data.returnOrder.remark = add_data.remark
        add_data.returnOrder.serviceManRemark = add_data.serviceManRemark
        add_data.returnOrder.wayEatPrice = add_data.wayEatPrice
        add_data.returnOrder.isBaitui = add_data.isBaitui
        add_data.returnOrder.baituiSignatoryPhone = add_data.baituiSignatoryPhone
        add_data.returnOrder.riseSignPrice = add_data.riseSignPrice
        add_data.returnOrder.driverRemark = add_data.driverRemark
        add_data.returnOrder.startTime = ''
        add_data.returnOrder.toLocation = add_data.fromLocation
        add_data.returnOrder.toLocationId = add_data.fromLocationId
        add_data.returnOrder.toLocationData.address = add_data.fromLocationData.address
        add_data.returnOrder.toLocationData.area = add_data.fromLocationData.area
        add_data.returnOrder.toLocationData.id = add_data.fromLocationData.id
        add_data.returnOrder.toLocationData.isSta = add_data.fromLocationData.isSta
        add_data.returnOrder.toLocationData.lnglat = add_data.fromLocationData.lnglat
        add_data.returnOrder.toLocationData.name = add_data.fromLocationData.name
        add_data.returnOrder.toLocationData.tel = add_data.fromLocationData.tel
        add_data.returnOrder.toLocationData.type = add_data.fromLocationData.type
        add_data.returnOrder.userId = add_data.userId
        add_data.returnOrder.useCarDutyUserId = add_data.useCarDutyUserId
        add_data.returnOrder.useCarCompanyName = add_data.useCarCompanyName
        add_data.returnOrder.useCarDutyInfo = add_data.useCarDutyInfo
        add_data.returnOrder.type = add_data.type
        add_data.returnOrder.price = add_data.price
        add_data.returnOrder.ensureMoney = add_data.ensureMoney
        add_data.returnOrder.points = add_data.points
        add_data.returnOrder.persons = add_data.persons
        add_data.returnOrder.cusInfo = add_data.cusInfo
        time_number2.value = ''
        aircraft_radio2.value = aircraft_radio.value
        chartered_bus_off2.value = chartered_bus_off.value
        getCarConfigurationType_list2.value = getCarConfigurationType_list.value
        add_cusName_list2.value = JSON.parse(JSON.stringify(add_cusName_list.value))
        add_cusName_index2.value = JSON.parse(JSON.stringify(add_cusName_index.value))
        passing_points_list2.value = JSON.parse(JSON.stringify(passing_points_list.value))
        passing_points_index2.value = JSON.parse(JSON.stringify(passing_points_index.value))
        // JSON.parse(JSON.stringify( ))
    } else if (data == 'false') {
        add_data.returnTime = ''
        add_data.returnOrder.cusMobile = ''
        add_data.returnOrder.cusName = ''
        add_data.returnOrder.days = ''
        add_data.returnOrder.endTime = ''
        add_data.returnOrder.flightDate = ''
        add_data.returnOrder.flightNum = ''
        add_data.returnOrder.flightTime = ''
        add_data.returnOrder.fromLocation = ''
        add_data.returnOrder.fromLocationId = ''
        add_data.returnOrder.fromLocationData.address = ''
        add_data.returnOrder.fromLocationData.area = ''
        add_data.returnOrder.fromLocationData.id = ''
        add_data.returnOrder.fromLocationData.isSta = ''
        add_data.returnOrder.fromLocationData.lnglat = ''
        add_data.returnOrder.fromLocationData.name = ''
        add_data.returnOrder.fromLocationData.tel = ''
        add_data.returnOrder.fromLocationData.type = ''
        add_data.returnOrder.landDate = ''
        add_data.returnOrder.needSeats = '0'
        add_data.returnOrder.priceNeedSeats = ''
        add_data.returnOrder.carConfig = ''
        add_data.returnOrder.personNum = ''
        add_data.returnOrder.receiveMsg = 'false'
        add_data.returnOrder.remark = ''
        add_data.returnOrder.serviceManRemark = ''
        add_data.returnOrder.wayEatPrice = '0'
        add_data.returnOrder.isBaitui = '0'
        add_data.returnOrder.baituiSignatoryPhone = ''
        add_data.returnOrder.riseSignPrice = '0'
        add_data.returnOrder.driverRemark = ''
        add_data.returnOrder.routeSimpleName = ''
        add_data.returnOrder.startTime = ''
        add_data.returnOrder.toLocation = ''
        add_data.returnOrder.toLocationId = ''
        add_data.returnOrder.toLocationData.address = ''
        add_data.returnOrder.toLocationData.area = ''
        add_data.returnOrder.toLocationData.id = ''
        add_data.returnOrder.toLocationData.isSta = ''
        add_data.returnOrder.toLocationData.lnglat = ''
        add_data.returnOrder.toLocationData.name = ''
        add_data.returnOrder.toLocationData.tel = ''
        add_data.returnOrder.toLocationData.type = ''
        add_data.returnOrder.userId = ''
        add_data.returnOrder.useCarDutyUserId = ''
        add_data.returnOrder.useCarCompanyName = ''
        add_data.returnOrder.useCarDutyInfo = ''
        add_data.returnOrder.type = ''
        add_data.returnOrder.price = ''
        add_data.returnOrder.ensureMoney = ''
        add_data.returnOrder.points = []
        add_data.returnOrder.persons = []
        add_data.returnOrder.cusInfo = []
        time_number2.value = ''
        aircraft_radio2.value = '包车'
        chartered_bus_off2.value = false
        getCarConfigurationType_list2.value = []
        add_cusName_list2.value = []
        add_cusName_index2.value = 0
        passing_points_list2.value = []
        passing_points_index2.value = 0
    } else {
        return ElMessage({
            message: '切换返程时有误！',
            type: 'warning',
        })
    }
}
//#endregion
//#region 提交按钮
// 重置数据
const clear_btn = () => {
    // 顺程数据
    add_data.cusMobile = ''
    add_data.cusName = ''
    add_data.days = ''
    add_data.endTime = ''
    add_data.flightDate = ''
    add_data.flightNum = ''
    add_data.flightTime = ''
    add_data.fromLocation = ''
    add_data.fromLocationId = ''
    add_data.fromLocationData.address = ''
    add_data.fromLocationData.area = ''
    add_data.fromLocationData.id = ''
    add_data.fromLocationData.isSta = ''
    add_data.fromLocationData.lnglat = ''
    add_data.fromLocationData.name = ''
    add_data.fromLocationData.tel = ''
    add_data.fromLocationData.type = ''
    add_data.landDate = ''
    add_data.needSeats = '0'
    add_data.priceNeedSeats = ''
    add_data.carConfig = ''
    add_data.personNum = ''
    add_data.receiveMsg = 'false'
    add_data.remark = ''
    add_data.serviceManRemark = ''
    add_data.wayEatPrice = '0'
    add_data.isBaitui = '0'
    add_data.baituiSignatoryPhone = ''
    add_data.riseSignPrice = '0'
    add_data.driverRemark = ''
    add_data.routeSimpleName = ''
    add_data.startTime = ''
    add_data.toLocation = ''
    add_data.toLocationId = ''
    add_data.toLocationData.address = ''
    add_data.toLocationData.area = ''
    add_data.toLocationData.id = ''
    add_data.toLocationData.isSta = ''
    add_data.toLocationData.lnglat = ''
    add_data.toLocationData.name = ''
    add_data.toLocationData.tel = ''
    add_data.toLocationData.type = ''
    add_data.userId = ''
    add_data.useCarDutyUserId = ''
    add_data.useCarCompanyName = ''
    add_data.useCarDutyInfo = ''
    add_data.serviceMan = ''
    add_data.type = ''
    add_data.price = ''
    add_data.ensureMoney = ''
    add_data.points = []
    add_data.persons = []
    add_data.cusInfo = []
    time_number1.value = ''
    aircraft_radio.value = '包车'
    chartered_bus_off.value = false
    getCarConfigurationType_list.value = []
    add_cusName_list.value = []
    add_cusName_index.value = 0
    passing_points_list.value = []
    passing_points_index.value = 0
    add_data.isReturnAdd = 'false'
    add_data.returnTime = ''
    add_data.returnOrder.cusMobile = ''
    add_data.returnOrder.cusName = ''
    add_data.returnOrder.days = ''
    add_data.returnOrder.endTime = ''
    add_data.returnOrder.flightDate = ''
    add_data.returnOrder.flightNum = ''
    add_data.returnOrder.flightTime = ''
    add_data.returnOrder.fromLocation = ''
    add_data.returnOrder.fromLocationId = ''
    add_data.returnOrder.fromLocationData.address = ''
    add_data.returnOrder.fromLocationData.area = ''
    add_data.returnOrder.fromLocationData.id = ''
    add_data.returnOrder.fromLocationData.isSta = ''
    add_data.returnOrder.fromLocationData.lnglat = ''
    add_data.returnOrder.fromLocationData.name = ''
    add_data.returnOrder.fromLocationData.tel = ''
    add_data.returnOrder.fromLocationData.type = ''
    add_data.returnOrder.landDate = ''
    add_data.returnOrder.needSeats = '0'
    add_data.returnOrder.priceNeedSeats = ''
    add_data.returnOrder.carConfig = ''
    add_data.returnOrder.personNum = ''
    add_data.returnOrder.receiveMsg = 'false'
    add_data.returnOrder.remark = ''
    add_data.returnOrder.serviceManRemark = ''
    add_data.returnOrder.wayEatPrice = '0'
    add_data.returnOrder.isBaitui = '0'
    add_data.returnOrder.baituiSignatoryPhone = ''
    add_data.returnOrder.riseSignPrice = '0'
    add_data.returnOrder.driverRemark = ''
    add_data.returnOrder.routeSimpleName = ''
    add_data.returnOrder.startTime = ''
    add_data.returnOrder.toLocation = ''
    add_data.returnOrder.toLocationId = ''
    add_data.returnOrder.toLocationData.address = ''
    add_data.returnOrder.toLocationData.area = ''
    add_data.returnOrder.toLocationData.id = ''
    add_data.returnOrder.toLocationData.isSta = ''
    add_data.returnOrder.toLocationData.lnglat = ''
    add_data.returnOrder.toLocationData.name = ''
    add_data.returnOrder.toLocationData.tel = ''
    add_data.returnOrder.toLocationData.type = ''
    add_data.returnOrder.userId = ''
    add_data.returnOrder.useCarDutyUserId = ''
    add_data.returnOrder.useCarCompanyName = ''
    add_data.returnOrder.useCarDutyInfo = ''
    add_data.returnOrder.type = ''
    add_data.returnOrder.price = ''
    add_data.returnOrder.ensureMoney = ''
    add_data.returnOrder.points = []
    add_data.returnOrder.persons = []
    add_data.returnOrder.cusInfo = []
    time_number2.value = ''
    aircraft_radio2.value = '包车'
    chartered_bus_off2.value = false
    getCarConfigurationType_list2.value = []
    add_cusName_list2.value = []
    add_cusName_index2.value = 0
    passing_points_list2.value = []
    passing_points_index2.value = 0
}
const ok_btn = (e) => {
    // 顺程判断
    if (!add_data.startTime) {
        return ElMessage({
            message: '请选择出发时间',
            type: 'warning',
        })
    } else if (!add_data.fromLocation) {
        return ElMessage({
            message: '请选择出发地址',
            type: 'warning',
        })
    } else if (!add_data.toLocation) {
        return ElMessage({
            message: '请选择目的地址',
            type: 'warning',
        })
    } else if (!add_data.personNum) {
        return ElMessage({
            message: '请输入预约人数',
            type: 'warning',
        })
    } else if (time_number1.value.length != 4) {
        return ElMessage({
            message: '时间不对请检查',
            type: 'warning',
        })
    } else if (!add_data.userId) {
        return ElMessage({
            message: '请检查客户',
            type: 'warning',
        })
    } else if (!add_data.cusName) {
        return ElMessage({
            message: '请输入联系人姓名',
            type: 'warning',
        })
    } else if (!add_data.cusMobile) {
        return ElMessage({
            message: '请输入联系人电话',
            type: 'warning',
        })
    } else if (add_data.cusMobile.length != 11) {
        return ElMessage({
            message: '联系人电话有误请检测',
            type: 'warning',
        })
    } else if (add_data.price === '') {
        return ElMessage({
            message: '请输入价格',
            type: 'warning',
        })
    }
    // 返程判断
    if (add_data.isReturnAdd == 'true') {

        if (!add_data.returnOrder.startTime) {
            return ElMessage({
                message: '请选择返程出发时间',
                type: 'warning',
            })
        } else if (!add_data.returnOrder.fromLocation) {
            return ElMessage({
                message: '请选择返程出发地址',
                type: 'warning',
            })
        } else if (!add_data.returnOrder.toLocation) {
            return ElMessage({
                message: '请选择返程目的地址',
                type: 'warning',
            })
        } else if (!add_data.returnOrder.personNum) {
            return ElMessage({
                message: '请输入返程预约人数',
                type: 'warning',
            })
        } else if (time_number2.value.length != 4) {
            return ElMessage({
                message: '返程时间不对请检查',
                type: 'warning',
            })
        } else if (!add_data.returnOrder.cusName) {
            return ElMessage({
                message: '请输入返程联系人姓名',
                type: 'warning',
            })
        } else if (!add_data.returnOrder.cusMobile) {
            return ElMessage({
                message: '请输入返程联系人电话',
                type: 'warning',
            })
        } else if (add_data.returnOrder.cusMobile.length != 11) {
            return ElMessage({
                message: '返程联系人电话有误请检测',
                type: 'warning',
            })
        } else if (add_data.returnOrder.price === '') {
            return ElMessage({
                message: '请输入返程价格',
                type: 'warning',
            })
        }
    }


    // 顺程数据
    if (add_data.fromLocation == '成都北站') {
        add_data.routeSimpleName = '接北站'
        for (let i = 0; i < aircraft_list2.value.length; i++) {
            if (add_data.fromLocation == aircraft_list2.value[i].station_name) {
                add_data.fromLocationId = aircraft_list2.value[i].id
                add_data.fromLocationData.address = aircraft_list2.value[i].station_name
                add_data.fromLocationData.area = aircraft_list2.value[i].station_name
                add_data.fromLocationData.id = aircraft_list2.value[i].id
                add_data.fromLocationData.lnglat = aircraft_list2.value[i].lng_lat
            }
        }
    } else if (add_data.fromLocation == '成都西站') {
        add_data.routeSimpleName = '接西站'
        for (let i = 0; i < aircraft_list2.value.length; i++) {
            if (add_data.fromLocation == aircraft_list2.value[i].station_name) {
                add_data.fromLocationId = aircraft_list2.value[i].id
                add_data.fromLocationData.address = aircraft_list2.value[i].station_name
                add_data.fromLocationData.area = aircraft_list2.value[i].station_name
                add_data.fromLocationData.id = aircraft_list2.value[i].id
                add_data.fromLocationData.lnglat = aircraft_list2.value[i].lng_lat
            }
        }
    } else if (add_data.fromLocation == '成都南站') {
        add_data.routeSimpleName = '接南站'
        for (let i = 0; i < aircraft_list2.value.length; i++) {
            if (add_data.fromLocation == aircraft_list2.value[i].station_name) {
                add_data.fromLocationId = aircraft_list2.value[i].id
                add_data.fromLocationData.address = aircraft_list2.value[i].station_name
                add_data.fromLocationData.area = aircraft_list2.value[i].station_name
                add_data.fromLocationData.id = aircraft_list2.value[i].id
                add_data.fromLocationData.lnglat = aircraft_list2.value[i].lng_lat
            }
        }
    } else if (add_data.fromLocation == '成都东站') {
        add_data.routeSimpleName = '接东站'
        for (let i = 0; i < aircraft_list2.value.length; i++) {
            if (add_data.fromLocation == aircraft_list2.value[i].station_name) {
                add_data.fromLocationId = aircraft_list2.value[i].id
                add_data.fromLocationData.address = aircraft_list2.value[i].station_name
                add_data.fromLocationData.area = aircraft_list2.value[i].station_name
                add_data.fromLocationData.id = aircraft_list2.value[i].id
                add_data.fromLocationData.lnglat = aircraft_list2.value[i].lng_lat
            }
        }
    } else if (add_data.toLocation == '成都北站') {
        for (let i = 0; i < aircraft_list2.value.length; i++) {
            if (add_data.toLocation == aircraft_list2.value[i].station_name) {
                add_data.toLocationId = aircraft_list2.value[i].id
                add_data.toLocationData.address = aircraft_list2.value[i].station_name
                add_data.toLocationData.area = aircraft_list2.value[i].station_name
                add_data.toLocationData.id = aircraft_list2.value[i].id
                add_data.toLocationData.lnglat = aircraft_list2.value[i].lng_lat
            }
        }
        add_data.routeSimpleName = '送北站'
    } else if (add_data.toLocation == '成都西站') {
        for (let i = 0; i < aircraft_list2.value.length; i++) {
            if (add_data.toLocation == aircraft_list2.value[i].station_name) {
                add_data.toLocationId = aircraft_list2.value[i].id
                add_data.toLocationData.address = aircraft_list2.value[i].station_name
                add_data.toLocationData.area = aircraft_list2.value[i].station_name
                add_data.toLocationData.id = aircraft_list2.value[i].id
                add_data.toLocationData.lnglat = aircraft_list2.value[i].lng_lat
            }
        }
        add_data.routeSimpleName = '送西站'
    } else if (add_data.toLocation == '成都南站') {
        for (let i = 0; i < aircraft_list2.value.length; i++) {
            if (add_data.toLocation == aircraft_list2.value[i].station_name) {
                add_data.toLocationId = aircraft_list2.value[i].id
                add_data.toLocationData.address = aircraft_list2.value[i].station_name
                add_data.toLocationData.area = aircraft_list2.value[i].station_name
                add_data.toLocationData.id = aircraft_list2.value[i].id
                add_data.toLocationData.lnglat = aircraft_list2.value[i].lng_lat
            }
        }
        add_data.routeSimpleName = '送南站'
    } else if (add_data.toLocation == '成都东站') {
        for (let i = 0; i < aircraft_list2.value.length; i++) {
            if (add_data.toLocation == aircraft_list2.value[i].station_name) {
                add_data.toLocationId = aircraft_list2.value[i].id
                add_data.toLocationData.address = aircraft_list2.value[i].station_name
                add_data.toLocationData.area = aircraft_list2.value[i].station_name
                add_data.toLocationData.id = aircraft_list2.value[i].id
                add_data.toLocationData.lnglat = aircraft_list2.value[i].lng_lat
            }
        }
        add_data.routeSimpleName = '送东站'
    } else {
        return ElMessage({
            message: '行程简称有误！',
            type: 'warning',
        })
    }
    if (aircraft_radio.value == '包车') {
        add_data.type = '1'
    } else if (aircraft_radio.value == '拼车') {
        add_data.type = '0'
    }

    for (let i = 0; i < cusOptions2.value.length; i++) {
        if (add_data.userId == cusOptions2.value[i].userId) {
            add_data.useCarCompanyName = cusOptions2.value[i].cusCompanyName
        }
    }

    for (let i = 0; i < getAllDutyOfCustom_list2.value.length; i++) {
        if (add_data.useCarDutyUserId == getAllDutyOfCustom_list2.value[i].ftUserId) {
            add_data.useCarDutyInfo = getAllDutyOfCustom_list2.value[i].ftUserId + '-' + getAllDutyOfCustom_list2.value[i].realName + '-' + getAllDutyOfCustom_list2.value[i].loginPhone
        }
    }

    for (let i = 0; i < getServiceMans_list2.value.length; i++) {
        if (add_data.serviceMan == getServiceMans_list2.value[i].ftUserId) {
            add_data.serviceMan = getServiceMans_list2.value[i].ftUserId + '-' + getServiceMans_list2.value[i].realName + '-' + getServiceMans_list2.value[i].loginPhone
        }
    }
    add_data.points = passing_points_list.value
    add_data.persons = add_cusName_list.value
    let hours = time_number1.value.substring(0, 2);
    let minutes = time_number1.value.substring(2);
    // 重新格式化为 'hh:mm'
    let formattedValue = `${hours}:${minutes}:00`;
    let startTime = add_data.startTime + ' ' + formattedValue

    if (!add_data.flightNum) {
        if (add_data.routeSimpleName.includes('接')) {
            add_data.landDate = startTime
        } else if (add_data.routeSimpleName.includes('送')) {
            add_data.flightDate = startTime
        }
    }
    let cusInfo = ''
    if (add_cusName_list.value.length > 0) {
        let cusInfo_one = {
            name: add_data.cusName,
            mobile: add_data.cusMobile
        }
        add_cusName_list.value.unshift(cusInfo_one)

        let cusInfo_list = []
        for (let i = 0; i < add_cusName_list.value.length; i++) {
            let cusInfo_data = ''
            if (add_cusName_list.value[i].name) {
                cusInfo_data = add_cusName_list.value[i].name + '-' + add_cusName_list.value[i].mobile
                cusInfo_list.push(cusInfo_data)
            }
        }
        cusInfo = cusInfo_list.join(',')
    } else {
        cusInfo = add_data.cusName + '-' + add_data.cusMobile
    }
    add_data.cusInfo = cusInfo
    add_cusName_list.value.shift()

    let ps = {
        cusInfo: add_data.cusInfo,
        cusMobile: add_data.cusMobile, // 乘车人电话
        cusName: add_data.cusName, // 乘车人
        days: add_data.days,
        endTime: add_data.endTime,
        flightDate: add_data.flightDate,
        flightNum: add_data.flightNum,
        flightTime: add_data.flightTime,
        fromLocation: add_data.fromLocation,
        fromLocationData: {
            address: add_data.fromLocationData.address,
            area: add_data.fromLocationData.area,
            id: add_data.fromLocationData.id,
            isSta: add_data.fromLocationData.isSta,
            lnglat: add_data.fromLocationData.lnglat,
            name: add_data.fromLocationData.name,
            tel: add_data.fromLocationData.tel,
            type: add_data.fromLocationData.type,
        },// 出发地
        fromLocationId: add_data.fromLocationId,
        isReturnAdd: add_data.isReturnAdd,
        landDate: add_data.landDate,
        needSeats: add_data.needSeats,
        priceNeedSeats: add_data.priceNeedSeats,
        carConfig: add_data.carConfig,
        personNum: add_data.personNum,
        receiveMsg: add_data.receiveMsg,
        remark: add_data.remark,
        serviceManRemark: add_data.serviceManRemark,
        wayEatPrice: add_data.wayEatPrice,
        isBaitui: add_data.isBaitui,
        baituiSignatoryPhone: add_data.baituiSignatoryPhone,
        riseSignPrice: add_data.riseSignPrice,
        driverRemark: add_data.driverRemark,
        returnTime: '',
        routeSimpleName: add_data.routeSimpleName,
        startTime: startTime,
        toLocation: add_data.toLocation,
        toLocationData: {
            address: add_data.toLocationData.address,
            area: add_data.toLocationData.area,
            id: add_data.toLocationData.id,
            isSta: add_data.toLocationData.isSta,
            lnglat: add_data.toLocationData.lnglat,
            name: add_data.toLocationData.name,
            tel: add_data.toLocationData.tel,
            type: add_data.toLocationData.type,
        },// 目的地
        toLocationId: add_data.toLocationId,
        userId: add_data.userId,
        useCarDutyUserId: add_data.useCarDutyUserId,
        useCarCompanyName: add_data.useCarCompanyName,
        useCarDutyInfo: add_data.useCarDutyInfo,
        serviceMan: add_data.serviceMan,
        type: add_data.type,
        price: Number(add_data.price) + Number(add_data.riseSignPrice) + Number(add_data.wayEatPrice),
        ensureMoney: add_data.ensureMoney,
        regularCarMoney: add_data.regularCarMoney,
        points: add_data.points,
        persons: add_data.persons,
        id: add_data.id,
        splitNum: 0,
        returnOrder: null,
    }
    if (ps.needSeats == '0' || ps.needSeats == '') {
        ps.needSeats = null
    }
    if (ps.priceNeedSeats == '0' || ps.priceNeedSeats == '') {
        ps.priceNeedSeats = null
    }

    // 返程数据
    if (add_data.isReturnAdd == 'true') {

        if (add_data.returnOrder.fromLocation == '成都北站') {
            add_data.returnOrder.routeSimpleName = '接北站'
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.returnOrder.fromLocation == aircraft_list2.value[i].station_name) {
                    add_data.returnOrder.fromLocationId = aircraft_list2.value[i].id
                    add_data.returnOrder.fromLocationData.address = aircraft_list2.value[i].station_name
                    add_data.returnOrder.fromLocationData.area = aircraft_list2.value[i].station_name
                    add_data.returnOrder.fromLocationData.id = aircraft_list2.value[i].id
                    add_data.returnOrder.fromLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
        } else if (add_data.returnOrder.fromLocation == '成都西站') {
            add_data.returnOrder.routeSimpleName = '接西站'
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.returnOrder.fromLocation == aircraft_list2.value[i].station_name) {
                    add_data.returnOrder.fromLocationId = aircraft_list2.value[i].id
                    add_data.returnOrder.fromLocationData.address = aircraft_list2.value[i].station_name
                    add_data.returnOrder.fromLocationData.area = aircraft_list2.value[i].station_name
                    add_data.returnOrder.fromLocationData.id = aircraft_list2.value[i].id
                    add_data.returnOrder.fromLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
        } else if (add_data.returnOrder.fromLocation == '成都南站') {
            add_data.returnOrder.routeSimpleName = '接南站'
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.returnOrder.fromLocation == aircraft_list2.value[i].station_name) {
                    add_data.returnOrder.fromLocationId = aircraft_list2.value[i].id
                    add_data.returnOrder.fromLocationData.address = aircraft_list2.value[i].station_name
                    add_data.returnOrder.fromLocationData.area = aircraft_list2.value[i].station_name
                    add_data.returnOrder.fromLocationData.id = aircraft_list2.value[i].id
                    add_data.returnOrder.fromLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
        } else if (add_data.returnOrder.fromLocation == '成都东站') {
            add_data.returnOrder.routeSimpleName = '接东站'
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.returnOrder.fromLocation == aircraft_list2.value[i].station_name) {
                    add_data.returnOrder.fromLocationId = aircraft_list2.value[i].id
                    add_data.returnOrder.fromLocationData.address = aircraft_list2.value[i].station_name
                    add_data.returnOrder.fromLocationData.area = aircraft_list2.value[i].station_name
                    add_data.returnOrder.fromLocationData.id = aircraft_list2.value[i].id
                    add_data.returnOrder.fromLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
        } else if (add_data.returnOrder.toLocation == '成都北站') {
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.returnOrder.toLocation == aircraft_list2.value[i].station_name) {
                    add_data.returnOrder.toLocationId = aircraft_list2.value[i].id
                    add_data.returnOrder.toLocationData.address = aircraft_list2.value[i].station_name
                    add_data.returnOrder.toLocationData.area = aircraft_list2.value[i].station_name
                    add_data.returnOrder.toLocationData.id = aircraft_list2.value[i].id
                    add_data.returnOrder.toLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
            add_data.returnOrder.routeSimpleName = '送北站'
        } else if (add_data.returnOrder.toLocation == '成都西站') {
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.returnOrder.toLocation == aircraft_list2.value[i].station_name) {
                    add_data.returnOrder.toLocationId = aircraft_list2.value[i].id
                    add_data.returnOrder.toLocationData.address = aircraft_list2.value[i].station_name
                    add_data.returnOrder.toLocationData.area = aircraft_list2.value[i].station_name
                    add_data.returnOrder.toLocationData.id = aircraft_list2.value[i].id
                    add_data.returnOrder.toLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
            add_data.returnOrder.routeSimpleName = '送西站'
        } else if (add_data.returnOrder.toLocation == '成都南站') {
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.returnOrder.toLocation == aircraft_list2.value[i].station_name) {
                    add_data.returnOrder.toLocationId = aircraft_list2.value[i].id
                    add_data.returnOrder.toLocationData.address = aircraft_list2.value[i].station_name
                    add_data.returnOrder.toLocationData.area = aircraft_list2.value[i].station_name
                    add_data.returnOrder.toLocationData.id = aircraft_list2.value[i].id
                    add_data.returnOrder.toLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
            add_data.returnOrder.routeSimpleName = '送南站'
        } else if (add_data.returnOrder.toLocation == '成都东站') {
            for (let i = 0; i < aircraft_list2.value.length; i++) {
                if (add_data.returnOrder.toLocation == aircraft_list2.value[i].station_name) {
                    add_data.returnOrder.toLocationId = aircraft_list2.value[i].id
                    add_data.returnOrder.toLocationData.address = aircraft_list2.value[i].station_name
                    add_data.returnOrder.toLocationData.area = aircraft_list2.value[i].station_name
                    add_data.returnOrder.toLocationData.id = aircraft_list2.value[i].id
                    add_data.returnOrder.toLocationData.lnglat = aircraft_list2.value[i].lng_lat
                }
            }
            add_data.returnOrder.routeSimpleName = '送东站'
        } else {
            return ElMessage({
                message: '行程简称有误！',
                type: 'warning',
            })
        }
        if (aircraft_radio2.value == '包车') {
            add_data.returnOrder.type = '1'
        } else if (aircraft_radio2.value == '拼车') {
            add_data.returnOrder.type = '0'
        }

        for (let i = 0; i < cusOptions2.value.length; i++) {
            if (add_data.userId == cusOptions2.value[i].userId) {
                add_data.returnOrder.useCarCompanyName = cusOptions2.value[i].cusCompanyName
                add_data.returnOrder.userId = add_data.userId
            }
        }

        for (let i = 0; i < getAllDutyOfCustom_list2.value.length; i++) {
            if (add_data.useCarDutyUserId == getAllDutyOfCustom_list2.value[i].ftUserId) {
                add_data.returnOrder.useCarDutyInfo = getAllDutyOfCustom_list2.value[i].ftUserId + '-' + getAllDutyOfCustom_list2.value[i].realName + '-' + getAllDutyOfCustom_list2.value[i].loginPhone
                add_data.returnOrder.useCarDutyUserId = add_data.useCarDutyUserId
            }
        }

        for (let i = 0; i < getServiceMans_list2.value.length; i++) {
            if (add_data.serviceMan == getServiceMans_list2.value[i].ftUserId) {
                add_data.returnOrder.serviceMan = getServiceMans_list2.value[i].ftUserId + '-' + getServiceMans_list2.value[i].realName + '-' + getServiceMans_list2.value[i].loginPhone
            }
        }
        add_data.returnOrder.points = passing_points_list2.value
        add_data.returnOrder.persons = add_cusName_list2.value
        let hours = time_number2.value.substring(0, 2);
        let minutes = time_number2.value.substring(2);
        // 重新格式化为 'hh:mm'
        let formattedValue = `${hours}:${minutes}:00`;
        let startTime = add_data.returnOrder.startTime + ' ' + formattedValue

        if (!add_data.returnOrder.flightNum) {
            if (add_data.returnOrder.routeSimpleName.includes('接')) {
                add_data.returnOrder.landDate = startTime
            } else if (add_data.returnOrder.routeSimpleName.includes('送')) {
                add_data.returnOrder.flightDate = startTime
            }
        }
        let cusInfo2 = ''

        if (add_cusName_list2.value.length > 0) {
            let cusInfo_one2 = {
                name: add_data.returnOrder.cusName,
                mobile: add_data.returnOrder.cusMobile
            }

            add_cusName_list2.value.unshift(cusInfo_one2)
            let cusInfo_list = []
            for (let i = 0; i < add_cusName_list2.value.length; i++) {
                let cusInfo_data = ''
                if (add_cusName_list2.value[i].name) {
                    cusInfo_data = add_cusName_list2.value[i].name + '-' + add_cusName_list2.value[i].mobile
                    cusInfo_list.push(cusInfo_data)
                }
            }
            cusInfo2 = cusInfo_list.join(',')
        } else {
            cusInfo2 = add_data.returnOrder.cusName + '-' + add_data.returnOrder.cusMobile
        }

        add_data.returnOrder.cusInfo = cusInfo2
        add_cusName_list2.value.shift()
        ps.returnTime = startTime
        let ps2 = {
            cusInfo: add_data.returnOrder.cusInfo,
            cusMobile: add_data.returnOrder.cusMobile, // 乘车人电话
            cusName: add_data.returnOrder.cusName, // 乘车人
            days: add_data.returnOrder.days,
            endTime: add_data.returnOrder.endTime,
            flightDate: add_data.returnOrder.flightDate,
            flightNum: add_data.returnOrder.flightNum,
            flightTime: add_data.returnOrder.flightTime,
            fromLocation: add_data.returnOrder.fromLocation,
            fromLocationData: {
                address: add_data.returnOrder.fromLocationData.address,
                area: add_data.returnOrder.fromLocationData.area,
                id: add_data.returnOrder.fromLocationData.id,
                isSta: add_data.returnOrder.fromLocationData.isSta,
                lnglat: add_data.returnOrder.fromLocationData.lnglat,
                name: add_data.returnOrder.fromLocationData.name,
                tel: add_data.returnOrder.fromLocationData.tel,
                type: add_data.returnOrder.fromLocationData.type,
            },// 出发地
            fromLocationId: add_data.returnOrder.fromLocationId,
            isReturnAdd: add_data.returnOrder.isReturnAdd,
            landDate: add_data.returnOrder.landDate,
            needSeats: add_data.returnOrder.needSeats,
            priceNeedSeats: add_data.returnOrder.priceNeedSeats,
            carConfig: add_data.returnOrder.carConfig,
            personNum: add_data.returnOrder.personNum,
            receiveMsg: add_data.returnOrder.receiveMsg,
            remark: add_data.returnOrder.remark,
            serviceManRemark: add_data.returnOrder.serviceManRemark,
            wayEatPrice: add_data.returnOrder.wayEatPrice,
            isBaitui: add_data.returnOrder.isBaitui,
            baituiSignatoryPhone: add_data.returnOrder.baituiSignatoryPhone,
            riseSignPrice: add_data.returnOrder.riseSignPrice,
            driverRemark: add_data.returnOrder.driverRemark,
            routeSimpleName: add_data.returnOrder.routeSimpleName,
            startTime: startTime,
            toLocation: add_data.returnOrder.toLocation,
            toLocationData: {
                address: add_data.returnOrder.toLocationData.address,
                area: add_data.returnOrder.toLocationData.area,
                id: add_data.returnOrder.toLocationData.id,
                isSta: add_data.returnOrder.toLocationData.isSta,
                lnglat: add_data.returnOrder.toLocationData.lnglat,
                name: add_data.returnOrder.toLocationData.name,
                tel: add_data.returnOrder.toLocationData.tel,
                type: add_data.returnOrder.toLocationData.type,
            },// 目的地
            toLocationId: add_data.returnOrder.toLocationId,
            userId: add_data.returnOrder.userId,
            useCarDutyUserId: add_data.returnOrder.useCarDutyUserId,
            useCarCompanyName: add_data.returnOrder.useCarCompanyName,
            useCarDutyInfo: add_data.returnOrder.useCarDutyInfo,
            serviceMan: add_data.returnOrder.serviceMan,
            type: add_data.returnOrder.type,
            price: Number(add_data.returnOrder.price) + Number(add_data.returnOrder.riseSignPrice) + Number(add_data.returnOrder.wayEatPrice),
            ensureMoney: add_data.returnOrder.ensureMoney,
            regularCarMoney: add_data.returnOrder.regularCarMoney,
            points: add_data.returnOrder.points,
            persons: add_data.returnOrder.persons,
            id: add_data.returnOrder.id,
            splitNum: 0,
        }
        if (ps2.needSeats == '0' || ps2.needSeats == '') {
            ps2.needSeats = null
        }
        if (ps2.priceNeedSeats == '0' || ps2.priceNeedSeats == '') {
            ps2.priceNeedSeats = null
        }
        ps.returnOrder = ps2

    }

    console.log(ps, '添加订单')
    add(ps).then(res => {
        add_data.needSeats = '0'
        add_data.returnOrder.needSeats = '0'
        if (res.code == 1) {
            if (e == 1) {
                add_data.serviceMan = add_data.serviceMan.split('-')[0]
                let router_list = $mainStore.router_list

                if (add_data.type == 1) {
                    let list_off = 0
                    for (let i = 0; i < router_list.length; i++) {
                        if (router_list[i].name == 'order_follow_up') {
                            list_off = 1
                        }
                    }
                    if (list_off != 1) {
                        let useRoute_data = {
                            path: '/order_follow_up',
                            name: 'order_follow_up',
                            meta: {
                                title: "订单跟进",
                                hidden: false, // 路由是否隐藏：true隐藏，false显示
                                icon: "SetUp",
                            },
                        }

                        router_list.push(useRoute_data)
                        localStorage.setItem('router_list', CircularJSON.stringify(router_list))
                        $mainStore.router_list = router_list

                    }
                    let useRoute_data2 = {
                        path: '/order_follow_up',
                        name: 'order_follow_up',
                        meta: {
                            title: "订单跟进",
                            hidden: false, // 路由是否隐藏：true隐藏，false显示
                            icon: "SetUp",
                        },
                    }
                    $mainStore.menu = !$mainStore.menu
                    $mainStore.router_name = useRoute_data2
                    $useRouter.push('/order_follow_up')
                } else if (add_data.type == 0) {
                    let list_off = 0
                    for (let i = 0; i < router_list.length; i++) {
                        if (router_list[i].name == 'carpool_list') {
                            list_off = 1
                        }
                    }
                    if (list_off != 1) {
                        let useRoute_data = {
                            path: '/carpool_list',
                            name: 'carpool_list',
                            meta: {
                                title: "拼车列表",
                                hidden: false, // 路由是否隐藏：true隐藏，false显示
                                icon: "Ticket",
                            },
                        }

                        router_list.push(useRoute_data)
                        $mainStore.router_list = router_list

                    }

                    let useRoute_data2 = {
                        path: '/carpool_list',
                        name: 'carpool_list',
                        meta: {
                            title: "拼车列表",
                            hidden: false, // 路由是否隐藏：true隐藏，false显示
                            icon: "Ticket",
                        },
                    }
                    $mainStore.menu = !$mainStore.menu
                    $mainStore.router_name = useRoute_data2
                    $useRouter.push('/carpool_list')
                }
                clear_btn()
            } else if (e == 2) {
                add_data.serviceMan = add_data.serviceMan.split('-')[0]
                add_data.returnOrder.serviceMan = add_data.returnOrder.serviceMan.split('-')[0]

            }

            return ElMessage({
                message: res.msg,
                type: 'success',
            })

        } else {
            return ElMessage({
                message: res.msg,
                type: 'warning',
            })
        }
    })

}


//#endregion

</script>

<style scoped lang='scss'>
.div_map {
    position: relative;
    left: 0;
    top: 0;
}

.map_input {
    width: 100%;
    position: absolute;
    z-index: 1;
    display: flex;
    justify-content: center;

}

.map_input2 {
    width: 100%;
    position: absolute;
    z-index: 1;
    display: flex;
    justify-content: center;
    top: 34px;

}

.div_bg:hover {


    background-color: darkgray;
}
</style>

<style>
.el-table .el-table__cell {
    padding: 0px !important;
}



#tab-aircraft_deliver {
    color: red;
}

#tab-train_deliver {
    color: red;
}

#tab-bus_deliver {
    color: red;
}

.col-items::-webkit-scrollbar {
    width: 5px !important;
}

.col-items>label {
    margin-left: 0px !important;
    margin-top: 5px;
    width: 100%;
}
</style>
